Search code examples
asp.net-mvc-3query-stringhttpmodulewebmatrixiis-express

Custom QueryStringModule (httpModules) not taken into account with WebMatrix


I created a QueryStringModule based on the one found here: https://stackoverflow.com/questions/6157150/mvc3-encrypted-querystring-parameters

It works fine when I run my web application with the VS2010 debugger, but it is not taken into account when I access my web application through WebMatrix.

Here is how I register it in the system.web section of my Web.config file:

<httpModules>
  <add name="QueryStringModule" type="MyProject.Lib.HttpModules.QueryStringModule" />
</httpModules>

Any clue on why WebMatrix would not use my QueryStringModule? My web site is an ASP.Net MVC 3 project using EF 4.1.


Solution

  • WebMatrix uses IIS Express 7.5 server and by default it runs in "Integrated" pipeline mode (In WebMatrix site settings you can see ".NET 4 (Integrated)" ). You have following two options

    Option-1: Keep your web.config file as is (i.e. classic mode http module registration) and change the pipeline mode to Classic

    1. Open your site in WebMatrix
    2. Naviagate to site settings in webMatrix
    3. Change .Net Framework version as shown below

    enter image description here

    Option-2: Don't change the site's pipeline mode, but update web.config file to register HTTP module in integrated mode (your web.config should look something like below). Take a look at http://msdn.microsoft.com/en-us/library/ms227673.aspx#Y873 to learn more about http module registration.

    <configuration>
      <system.webServer>
        <modules>
           <add name="QueryStringModule" type="MyProject.Lib.HttpModules.QueryStringModule" />
        </modules>
      </system.webServer>
    </configuration>