Url Rewriting

Last post 07-01-2009 6:43 AM by mihir.mone. 3 replies.

Sort Posts:

  • Url Rewriting

    06-30-2009, 1:09 AM
    • Member
      258 point Member
    • mihir.mone
    • Member since 05-20-2008, 12:59 AM
    • Mumbai, India
    • Posts 73

    Hello,

    I am working on a web application in ASP.net 2.0 with IIS7, which needs Url Rewriting for some part of it.

    I created HttpModule to serve the purpose (handled BeginRequest event).

    When I try and register HttpModule under <system.webServer> section, I can not see <modules> section listed in the intellisence. Hence I typed in, but it didn't work for me.

    Application should allow paths like - http://mysite/mihir (redirect to - http://mysite/employee.aspx?name=mihir)

    It was pretty easy with IIS 6.0, but I am facing this issue with IIS 7.0.

    Would appriciate for your help.

    Many Thanks,

    Mihir.

    Mihir,
    Software Professional
    http://mihirhere.spaces.live.com
  • Re: Url Rewriting

    06-30-2009, 7:32 AM
    • Contributor
      5,222 point Contributor
    • RickNZ
    • Member since 01-01-2009, 3:43 AM
    • Nelson, New Zealand
    • Posts 863

    Interesting, <modules> is in Intellisense for me with .NET 3.5....


    For IIS 7, you should register HttpModules in two places:

    <system.web>

      <httpModules>

        <add name="MyModule" type="Namespace.Class" />

      </httpModules>

    </system.web>


    And here:

    <system.webServer>

      <modules>

        <add name="MyModule" type="Namespace.Class" />

      </modules>

    </system.webServer>


    You might also want to add preCondition="managedHandler" to the second instance, if your code is intended only for aspx files and not for static files too.

    The different registrations have to do with things like Cassini and Classic vs. Integrated mode in IIS 7.  You can always set a breakpoint to make sure your code is actually running.

  • Re: Url Rewriting

    06-30-2009, 7:47 AM
    • Member
      258 point Member
    • mihir.mone
    • Member since 05-20-2008, 12:59 AM
    • Mumbai, India
    • Posts 73

    Thanks Rick,

    Yes, I am not getting this <modules> in intellisence in ASP.net 2.0

    I understand that I can register my module with <system.web><httpModules>, but my web server has IIS 7, where I will be using Integrated pipeline over classic, hence I am trying with <system.webSever><modules>.

    I want to invoke the module for any path without any extension (e.g. http://mysite/mihir , this would be re-written as http://mysite/employee.aspx?name=mihir )

    My problem is - <system.webSever> doesnt show <modules> in intellisence, and though I type in the whole <modules> section.. it doesn't work.

    Mihir,
    Software Professional
    http://mihirhere.spaces.live.com
  • Re: Url Rewriting

    07-01-2009, 6:43 AM
    Answer
    • Member
      258 point Member
    • mihir.mone
    • Member since 05-20-2008, 12:59 AM
    • Mumbai, India
    • Posts 73

    After spending a lot of time I came to know that, sections under <system.webServer> are locked.

    If user has administrative privilages, sections can be unlocked.

    You can fire command -'appcmd.exe' though command prompt.

    Mihir,
    Software Professional
    http://mihirhere.spaces.live.com
Page 1 of 1 (4 items)