Pages .aspx in View folder in ASP.MVC project

0

Good afternoon guys,

I am a beginner in MVC architecture and am having a question in an ASPNET.MVC project. I would like to know if it is possible in the "View" folder of the project, put an "aspx" page together with the "cshtml" files.

If I put the file in the root of the web application, it rises quietly but when put in the View folder it generates error 404.

I searched for some solutions on the web but did not find much.

Thank you in advance,

Thank you!

    
asked by anonymous 27.07.2018 / 21:57

1 answer

2

In case of a migration I recommend that you create a folder called "Legacy" or as "Pages" itself (if you do not want to leave this intention explicit) and add Ignore of that route to your RouteConfig which is located in the directory App_Start , so MVC will ignore this route in its management.

See the example below

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");            

        routes.IgnoreRoute("{diretorio}", new { diretorio = "Paginas" });

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
}
    
27.07.2018 / 22:56