How can my route use optional parameters in the middle of the URL using ASP MVC3?

后端 未结 1 1614
再見小時候
再見小時候 2021-01-18 21:13

I would like my URLs to use the convention:

/{controller}/{id}/{action}

rather than

/{controller}/{action}/{id}


        
相关标签:
1条回答
  • 2021-01-18 21:46

    I think you probably need two separate routes for this.

    routes.MapRoute(
                "CampaignDetail",
                "{controller}/{id}/{action}",
                new { controller = "Campaign", action = "Index" } 
            );
    
    routes.MapRoute(
                "Campaign",
                "{controller}/{action}",
                new { controller = "Campaign", action = "Index" } 
            );
    
    0 讨论(0)
提交回复
热议问题