IIS lookup mapping does not work for ASP.NET

I set up wildcard matching in IIS 6 by adding "C: \ WINDOWS \ Microsoft.NET \ Framework \ v2.0.50727 \ aspnet_isapi.dll" and guaranteeing "Check that the file exists" is unchecked:

  • in the websites directory in IIS
  • on the website

However, after iisreset, when I go to http: //myserver/something.gif , I still get the IIS 404 error, not asp.net.

Is there something I missed?

Precisions:

  • it is not for using ASP.NET MVC
  • I would prefer not to use custom iis 404 error pages, since I have an httpmodule for reporting errors (this is a low internal traffic site, so limiting template matching performance is not a problem;))
+4
source share
3 answers

You need to add the HTTP handler to your web configurator for gif files:

<system.web> <httpHandlers> <add path="*.gif" verb="GET,HEAD" type="System.Web.StaticFileHandler" validate="true"/> </httpHandlers> </system.web> 

This causes .Net to process the file, then you get a .Net error.

Server error in application "/".

Resource is not found. Description: HTTP 404. The resource you are looking for (or its dependencies) may have been deleted, its name changed or temporarily unavailable. Review the following URL and make sure it is spelled correctly.

Requested URL: /test.gif


Version Information: Microsoft.NET Framework Version: 2.0.50727.1433; ASP.NET Version: 2.0.50727.1433

+4
source

To do this, you can try to use your own mistakes. Go to the "User Errors" in the website properties and set parameter 404 to the URL on your website. Like /404.aspx, it exists.

With aspnet_isapi, you want to use the HttpModule to handle your wildcards. e.g. http://urlrewriter.net/

0
source

You cannot use wilcard mapping without using ASP.net routing or a URL entry or some kind of URL mapping mechanism.

If you want to make 404, you need to configure it in web.config -> User Errors.
Then you can redirect to other pages if you want.

New in 3.5 SP1, you set RedirectMode to "responseRewrite" to avoid redirecting to the user error page and leaving the URL in the browser untouched.

Another way to do this is to catch the error in global.aspx and redirect. Comment on the answer if you need additional instructions.

0
source

Source: https://habr.com/ru/post/1276920/


All Articles