Sunday, February 22, 2015

IIS / ASP.NET - Disabling Compatibility Mode/View (Internet Explorer)

In ASP.NET, if you need to disable compatibility view of the end users using your application, you can override the respective browser (Internet Explorer) compatibility mode, by setting the compatibility mode to Edge. By using this setting, the users of the web application, will render using the latest rendering engine available. If in the scenario you don't want to use the latest, you can also define other standards, such as IE8, IE9, etc.

This can be defined in the master page/view using the following meta tag within the <head> section:


   ...
   

Note: The X-UA-Compatible meta tag will need to be the first meta tag, in the circumstance that setting the IE rendering engine to Edge, is not working as intended.

and web.config, by adding a custom header using X-UA-Compatible to the response headers,

  
    
      ...
      
    
  

IIS / ASP.NET - Run all Managed Modules for All Requests (RAMMFAR)

When initially creating an ASP.NET web application, RunAllManagedModulesForAllRequest is enabled by default. If enabled, every request that passes through the ASP.NET pipeline, is treated as a managed modules (or handlers). When all modules are managed, including static content, there are possible performance implications. If you are utilizing a distributed cache provider, such as App Fabric, an implication includes that all managed resources, including static content are passed to the distributed cache (as managed resources), which adds a level of overhead, even if not required. The solution to optimizing your web application, is to disable runAllManagedModulesForAllRequests (RAMMFAR), and add defined locations for your static resources within your web configuration file. The static resources can include but are not limited to CSS, Images, and Scripts.

Firstly, you will want to add location segments for each file/folder location, within the configuration element.

...

   
   
      
         
            
         
      
   
   
   
   
      
         
            
         
      
   
   ...

Once completed, you will see the following section, under system.webServer.
  
     
   
 
You will need to change the value of runAllManagedModulesForAllRequests to false. Also, if you were to stop here, you would potentially get errors from utilizing Bundles within your project, failing upon a Script Render. You will need to ensure you properly add the BundleModule to remediate the errors.
  
     
   
      
      
      
      
      
      
      ...
     
 
Note: In some scenarios, there may be other bundles, that reference static resources that aren't directly accessible in your project. In this scenario, the respective bundle/handler may need to be added to the system.webServer section, similar to the BundleModule. One example, is MiniProfiler, which has resources located at /mini-profiler-resources.

    ...