简体   繁体   中英

global.asax rewriting not working live

I have implemented a URL rewriting in the global.asax file, it works perfectly on my machine but not on the live enviroment. Any idea what shall I look at to solve the problem? Thanks

First make sure that you have IIS set to pass all relevant URIs to the ASP.NET engine. If the paths all end with a limited number of so-called "extensions" (eg .html, .png to make the URI look like a file-path with a file-extension) then you need just map this particular extension (copy-paste from that for .aspx).

If you need it to handle (or at least examine and see if it should handle) a wider range of URIs you need to set a wildcard handler. Different versions of IIS differ in how this is done (IIRC 5.0 to 6.0 was when the change happened). If the version has a place to enter wildcard mappings on the part of the dialog that deals with script-mappings (or "handler mappings" from 7.0 on) then use this, if not, define a mapping for .* (don't worry about the period, it will still match URIs even if they don't have one).

There's other things that could be going wrong, but this is your starting point, and if it isn't right, it'll certainly cause this problem.

The web server built into Visual Studio uses the ASP.NET engine to handle all file types, but IIS only uses the ASP.NET engine to handle file types that actually are executed.

So, the Application_BeginRequest event (and similar) in the global.asax file only happens for file types like .aspx or .asmx , not file types like .html , .css or .jpg .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM