locked
IHttpModule works in Visual Studio + In IIS returns 404 RRS feed

  • Question

  • User879129561 posted

    Hello everyone,

    I have been stuck on one problem for a couple of days and would appreciate any input you may have.

    I have written an IHttpModule class which is in my App_Code folder.

    I added an HttpModules reference in my web.config class.

    The IHttpModule is doing a url rewrite.

    For example -> http://www.example.com/MyBlogUserBlogtitle.html?docID=15 -> http://www.example.com/blog.aspx?docID=15

    The page is populated with a bunch of virtual links similar to those shown above.

    In Visual Studio, all the links are browsable.

    However, in IIS, if I select the website and click browse, the initial page is displayed. On that page, I can click on any link, but only

    the first virtual url gets resolved. Subsequent requests return 404.

    The website is configured on the local ip: for example, 10.0.0.5

    If I try to browse this IP in the web browser, it shows the page, but every virtual link returns Http 404.

    In IIS, if you browse it, it works for the first link and then not afterwards.

    Technically, 404 should be impossible in the IhttpModule because if the file doesn't exist it serves a default page.

    Also, I verified that it's not a link specific problem.

    Has anyone encountered this problem?

    Friday, June 8, 2012 3:31 PM

Answers

  • User879129561 posted

    Hello I solved this problem.

    The problem is that the in the dev environment all the calls are automatically routed through asp.net.

    My virtual url had a .html extension.

    By default IIS tries to hand this extension directly, so it gives the 404 error.

    To verify you have this problem, type in a virtual URL which DOESN'T EXIST but ensure it has a .aspx extension.

    By default IIS is configured to route .aspx. Provided that your virtual url is properly formed, it should be handled by the HTTP module.

    If that is true, they can configure IIS to handle your virtual url as follows:

    In my case, I needed to add the .html extension and associated it with the aspnet_isapi.dll

    a) In IIS, right click on the website

    b) Goto properties

    c) Click on the Home Director Tab

    d) Click the "Configuration" button.

    e) Click Add

    f) Type in the extension you want asp.net to handle, in my case .html

    g) Select the executable. In my case: C:\Windows\Microsoft.net\Framework\v2.0.50727\aspnet_isapi.dll

    h) Now the virtual urls of type .html will be handled by asp.net

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 9, 2012 12:55 PM

All replies

  • User-851967432 posted

    I haven't encountered this but are you sure the hardcoded URL's do not have a typographical error?

    Friday, June 8, 2012 3:45 PM
  • User879129561 posted

    Hi adam,

    Yes, I'm sure there is no typographical error because it works in visual studio.

    Also, one of the issues is that I have a logger. I am logging every rewrite request. And those requests aren't showing up in the log file.

    So even if there was a typo, at the minimum the logger should show that

    Friday, June 8, 2012 4:32 PM
  • User879129561 posted

    Hello I solved this problem.

    The problem is that the in the dev environment all the calls are automatically routed through asp.net.

    My virtual url had a .html extension.

    By default IIS tries to hand this extension directly, so it gives the 404 error.

    To verify you have this problem, type in a virtual URL which DOESN'T EXIST but ensure it has a .aspx extension.

    By default IIS is configured to route .aspx. Provided that your virtual url is properly formed, it should be handled by the HTTP module.

    If that is true, they can configure IIS to handle your virtual url as follows:

    In my case, I needed to add the .html extension and associated it with the aspnet_isapi.dll

    a) In IIS, right click on the website

    b) Goto properties

    c) Click on the Home Director Tab

    d) Click the "Configuration" button.

    e) Click Add

    f) Type in the extension you want asp.net to handle, in my case .html

    g) Select the executable. In my case: C:\Windows\Microsoft.net\Framework\v2.0.50727\aspnet_isapi.dll

    h) Now the virtual urls of type .html will be handled by asp.net

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 9, 2012 12:55 PM