views:

176

answers:

4

Hi,

I'm developing an ASP.NET MVC application on IIS7 and I need to rewrite requests to all files from a directory in my application and it's subdirectories to another directory. The files are images, stylesheets, classic webforms files and vanilla html documents.

What's the easiest way to achieve this? I've already tried installing the ManagedFusion's URL rewriter, but it just gives me an access denied error on all URLs since I installed it. I'm not even sure if it's compatible with ASP.NET MVC.

Thanks,

Adrian

+3  A: 

Starting with IIS7, IIS ships with a module that can be used for rewriting URLs.

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

"The Microsoft URL Rewrite Module for IIS 7.0 provides flexible rules-based rewrite engine that can be used to perform broad spectrum of URL manipulation tasks, including, but not limited to:

  • Enabling user friendly and search engine friendly URL with dynamic web applications;
  • Rewriting URL’s based on HTTP headers and server variables;
  • Web site content handling;
  • Controlling access to web site content based on URL segments or request metadata."
Brad Tutterow
A: 

Helicon has a nice tool for this, which costs $99. It's mostly the same as mod_rewrite, so it's easy to find useful help. I've had pretty good luck with it.

Brian
+1  A: 

Be careful with url rewriting and "classic webforms documents"--mainly url rewriting can break postback.

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


Thanks for the clarification. Url rewriting could make quite a bit of sense here. Another option that could be cleaner is to setup a virtual directory (really series of virtual directories) to give the crystal reports the path it needs.

If you want to do the rewrite thing, then use the native url rewrite module--it is very slick and should be the best supported.

Wyatt Barnett
It's a long story... I'm using Crystal Reports (that's the legacy part) in my app simply by including reports via an IFrame. CR expects all visual resources, popups etc in a special directory. Unfortunately the path to those resources is so deep that I can't check them into version control because it would exceed the maximum path length that Tortoise SVN supports, unless I move my entire web project, which would cause even more trouble.
Adrian Grigore
Ew, CR. See updated answer for a clairified answer.
Wyatt Barnett
+1  A: 

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

Nick Berardi