4

I am trying to integrate an old ReportViewer Webform into my current MVC3 project. I would like it to be available at http://<server>/Reports/ViewReport.aspx. At first I created a folder in the root of my project titled Reports, dumped the page in there, and it worked just fine.

However, I now have an Area also called Reports, and I had to get rid of the folder in order for the default routing to work correctly.

How can I configure my routing so that the Webform URL appears to be coming from Reports even if it's physically elsewhere in my project?

user1013571
  • 125
  • 1
  • 7

1 Answers1

1

The easiest way to do this is to use IIS URL Rewrite module. No changes to your application's code or routing. Just place your webpage somewhere in some non-MVC related folder that is also accessible.

http://www.iis.net/download/urlrewrite

But otherwise you could try putting your file directly in area folder as the RouteCollection.RouteExistingFiles is by default false which means that your file should be processed by the usual Asp.net web forms pipeline.

The most important thing is though that you don't put your file inside a folder with configured System.Web.HttpNotFoundHandler handler. By default Views folders have these configured so files within sub-folder tree are inaccessible from request level. Application of course can access them (that's how MVC works anyway).

Robert Koritnik
  • 103,639
  • 52
  • 277
  • 404
  • 1
    Just make sure your URL rule is for `/Reports/ViewReport.aspx` only, if you do it for the entire `/Reports` path, you will break the routing to your Controller. – Jesse Webb Aug 23 '12 at 22:23
  • @JesseWebb: **Exactly** and thanks for pointing it out because I thought it was self evident. – Robert Koritnik Aug 23 '12 at 22:41