Installing Osano in ASP.NET

  • Updated

In Osano, after creating and publishing your configuration, the "Get Code" button will become active. This button will provide you with the osano.js.


Cookie Consent - Get Code


To add custom JavaScript code to the global <head> section of your ASP application, you can modify the layout file accordingly. Note: this is one way to make changes, but your application's needs may differ from what is laid out here. 

  • Open the layout file (_Layout.cshtml) in a code editor.

  • Locate the <head> section in the layout file.

  • Add your custom JavaScript code directly within the <head> section. For example:

<!-- Other head content -->

// Custom JavaScript code
$(document).ready(function() {
// Your Osano code here
  • Save the changes to the layout file.

By placing the custom JavaScript code directly within the layout file's <head> section, it will be included in the global <head> section for all views that use that layout. This way, the JavaScript code will be loaded and executed on every page of your ASP.NET MVC application.


Post Installation

Once the osano.js is in your site's <head>, it will begin identifying scripts and cookies that exist on your site. This process can take a few minutes to a few hours, depending on the level of site traffic.

Important: Remember, the osano.js defaults to "Listener" mode. In Listener mode, the consent manager will NOT block any trackers and will NOT display dialogs to your visitors. You can use Osano in "Listener" mode and another CMP simultaneously if you migrate away from another provider. This way, there are no gaps in compliance.

Once you have collected enough reports from osano.js, you can work with your other business units to identify and classify all cookies/scripts/and local storage items. This exercise ensures that no "strictly necessary" scripts, cookies, or local storage get blocked.

We recommend that users remain in "Listener" mode until you have discovered and classified all relevant scripts and cookies. 


Cookie Consent - Modes


After you have appropriately categorized each script and cookie, you can enable Permissive or Strict Mode and publish these changes. 

You will now see the consent dialog on your website!