简体   繁体   中英

asp.net (and mvc) possible to alter iis rewrite rules from code

I know this has been asked a number of times, but I haven't see an actual answer yet- using asp.net, and possibly with mvc, is it possible to alter the rewrite rules from the application?

The normal answer for this is "use mvc routing", but from what I understand, this adds significant overhead for files that would otherwise be considered static - thus, it would be ok to use IIS rewrite for things like css files and images as it will still perform well, but you wouldnt want to serve these static resources up from an mvc/asp.net app as it could create a bottleneck.

Thus: being able to alter the rules for IIS could be a good way to allow a program to create high-performance aliasing, without requiring hand editing of the rules.

make sense?

You could of course modify the Application_BeginRequest of your Global.asax file in ASP.NET(and MVC) to perform URL Rewrites. You could alternatively create a custom HTTP Module to do the URL rewriting, because it gives you the additional flexibility of rearranging it's order in the IIS pipeline.

MVC routing works fine for your case as well, since by default IIS uses seperate modules which will process requests for your static content.

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