What's the easiest way to rewrite Urls in ASP.NET MVC / IIS7?

I am developing an ASP.NET MVC application on IIS7 and I need to rewrite requests for all files from a directory in my application, and these are subdirectories in a different directory. The files are images, stylesheets, classic web form files, and vanilla html documents.

What's the easiest way to achieve this? I already tried to set the ManagedFusion rewrite url, but it just gives me an error with access denied in all urls since I installed it. I'm not even sure if it's ASP.NET MVC compatible.

Thank,

Adrian

+2


source to share


4 answers


Starting with IIS7, IIS comes with a module that you can use to rewrite URLs.

http://learn.iis.net/page.aspx/460/using-url-rewrite-module/



"The Microsoft URL Rewrite Module for IIS 7.0 provides a flexible rule-based rewriting engine that can be used to perform a wide variety of URL management tasks, including but not limited to:

  • Enabling user friendly and search URL with dynamic web applications;
  • Rewriting URLs based on HTTP headers and server variables;
  • Website content processing;
  • Control access to website content based on URL segments or request metadata.
+3


source


Be careful with URL rewriting and "classic web form documents" - mostly URL rewriting can break postbacks.

Anyway, it looks like you have a legacy app that you are working with. Why not just add an ignored route and let IIS / ASPNET handle your business natively?




Thanks for the clarification. Editing the Url might make a little sense here. Another option, which might be cleaner, is to set up a virtual directory (really a series of virtual directories) to give the crystal reports on which path it needs.

If you want to do the rewriting, use your own url rewrite module - it's very slick and should be best supported.

+1


source


There is also .NET URL Rewriter and reverse proxy , which is the same as mod_rewrite on Apache, and completely free unlike the others.

+1


source


Helicon has a good tool for this that costs $ 99. It's basically the same as mod_rewrite, so it's easy to find helpful help. I am very lucky with this.

0


source







All Articles