How to route a .aspx page in asp.net mvc 3 project?

后端 未结 4 1452
陌清茗
陌清茗 2020-12-01 10:02

I have a .aspx page in the following path:

Areas/Management/Views/Ticket/Report.aspx

I want to route that to the following path in my brows

4条回答
  •  眼角桃花
    2020-12-01 10:32

    you are doing it opposite. this maps your url Areas/Management/Views/Ticket/Report.aspx to { controller = "Reports", action = "Tickets" }
    what u should do instead is set the url as
    Reports/Tickets EDIT:- you can create a routeHandler just for routing to this .aspx page.. like this.

    public class ASPXRouteHandler : IRouteHandler 
    { 
       public IHttpHandler GetHttpHandler(RequestContext requestContext) 
       { 
    
         return BuildManager.CreateInstanceFromVirtualPath("~/Areas/Management/Views/Ticket/Report.aspx",  typeof(Page)) as Page; 
       } 
    }
    

    then u can add ur route to the existing routes table using

    Route customRoute = new Route("Reports/Ticket",null, new ASPXRouteHandler()); 
          routes.Add(customRoute); 
    

提交回复
热议问题