R – What’s the simplest way to rewrite Urls in ASP.NET MVC / IIS7

asp.netiis-7url-rewriting

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

Best Answer

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."