0

I have a MVC4 application in which I need to add some old aspx pages. I added it in Views/Report folder like this

enter image description here

I have added the following code to routeconfig to avoid routing for aspx pages.

routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");

but still when I try to open the page, I get resource not found error from server.

Can anyone show me what I am missing.

Jonesopolis
  • 25,034
  • 12
  • 68
  • 112
Sujith Kp
  • 1,075
  • 3
  • 14
  • 27
  • semi-duplicate of [How to route a .aspx page in asp.net mvc 3 project?](http://stackoverflow.com/questions/10175200/how-to-route-a-aspx-page-in-asp-net-mvc-3-project) – Dylan Corriveau Jul 31 '14 at 13:05
  • @DylanCorriveau Corriveau in the above solution they are mapping a route to a physical file. I don't think I want a routing definition here since I have said to ignore .aspx requests. – Sujith Kp Jul 31 '14 at 13:30
  • But if you've written to ignore routes, then it will return the message that the resource cannot be found (I believe...), which would make sense in this context. You would probably need to either remove the ignoreroute, or just add a special mapping case for the report directory – Dylan Corriveau Jul 31 '14 at 13:35
  • @DylanCorriveau what routes.IgnoreRoute says is to remove this type of paths from following mvc route. these paths will served based on the physical path. – Sujith Kp Jul 31 '14 at 14:52

1 Answers1

2

If you look in the /Views folder, you will find an additional Web.config file in addition to the one everyone knows and loves in the root of your ASP.NET application. This is a built-in feature where folder paths inherit properties defined by web.config files defined in parent folders, but can override them with their own configurations. In the case of all default MVC apps, there's a problematic line for you like:

<system.web>
    <httpHandlers>
      <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
    </httpHandlers>
...

The easiest solution would be to keep your aspx's out of the /Views folder.

welegan
  • 3,013
  • 3
  • 15
  • 20
  • BTW, don't remove that line if you care about security at all, the point of it is to make sure no one can see what the raw text of your views are by simply requesting them as files via http. – welegan Jul 31 '14 at 14:54