404 Redirecting for non aspx pages

后端 未结 2 638
无人及你
无人及你 2020-12-03 17:24

I am using the web.config code below to redirect requests to missing pages to a 404 error handling page:



        
2条回答
  •  暖寄归人
    2020-12-03 17:57

    As dbaseman states this is because the asp.net handlers are not called for non-asp.net files. An easy way to force the asp.net handler to operate on all requests is to set the following in your web.config.

    
        
    
    

    This tells IIS to run through all of the managed modules for all requests such as .html, .jpg, .css, .js, etc. This is typically frowned upon as it just introduces extra processing and latency.

    http://www.hanselman.com/blog/BackToBasicsDynamicImageGenerationASPNETControllersRoutingIHttpHandlersAndRunAllManagedModulesForAllRequests.aspx

    Another option to try (cleaner than the above) was posted as an answer here: https://stackoverflow.com/a/6661699/701062

提交回复
热议问题