Removing part of the link in the ASP.NET MVC routes

1

My RouteConfig is configured like this:

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

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

My access to controllers and actions is occurring normally, but I have calls to * .aspx files for my reports, these files are in a folder called " Reports ", when I'm going to call they are returning me this way to url: " link "

In this way it does not find the respective file.

I need to access the url like this: " link "

I found some examples like:

routes.Ignore("{*allaspx}", new {allaspx=@".*\.aspx(/.*)?"});

routes.IgnoreRoute("{*favicon}", new {favicon=@"(.*/)?favicon.ico(/.*)?"});

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

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

But I did not succeed with any of these examples.

    
asked by anonymous 07.03.2016 / 13:41

2 answers

0

Above the path Default , use this:

routes.MapRoute(
    name: "Relatorios",
    url: "{empresa}/Relatorios/{action}",
    defaults: new { empresa = "", controller = "Relatorios", action = "Index" }
);
    
08.03.2016 / 19:55
0

You can create another route or modify the one that you are and leave as below:

     routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new {controller = "Login", action = "Index", id = UrlParameter.Optional }

);
    
08.03.2016 / 19:48