1

In my ASP.NET MVC5 application, in root folder of myProject I've a folder "subfolder" that contains page.aspx . When I perform some action in my controller, it redirect to subfolder/page.aspx, but in the address bar of browser is shown "www.mysite.com/subfolder/page.aspx". My goal is to redirect to page.aspx without allowing navigation through folders and showing in address bar "www.mysite.com/page". Any idea?

Pinturikkio
  • 1,490
  • 1
  • 14
  • 28
  • possible 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) – jamesSampica Mar 04 '15 at 17:59

1 Answers1

0

Just use MapPageRoute to route to static files in the Route.config.

routes.MapPageRoute(
    routeName: "aspx",
    routeUrl: "page",
    physicalFile: "~/Subfolder/page.aspx",
    checkPhysicalUrlAccess:false
);

Additionally if you want to disallow navigating to the physical url setup a deny in the web.config

<location path="Subfolder/page.aspx">
    <system.web>
      <authorization>
        <deny users="*"/>
      </authorization>
    </system.web>
</location>
jamesSampica
  • 12,230
  • 3
  • 63
  • 85