ASP.NET MVC Routing two GUIDs

前端 未结 2 1620
半阙折子戏
半阙折子戏 2021-02-10 06:49

I have an action taking two GUIDs:

public class MyActionController : Controller
{
  //...

  public ActionResult MoveToTab(Guid param1, Guid param2)
  {
    //..         


        
2条回答
  •  逝去的感伤
    2021-02-10 07:17

    Yes, it is possible to map your parameters to System.Guid

    routes.MapRoute(
        "MoveToTab",
        "{controller}/{action}/{param1}/{param2}",
        new { controller = "MyAction", action = "MoveToTab",
            param1 = System.Guid.Empty, param2 = System.Guid.Empty }
    );
    

    or

    routes.MapRoute(
        "MoveToTab2",
        "myaction/movetotab/{param1}/{param2}",
        new { controller = "MyAction", action = "MoveToTab",
            param1 = System.Guid.Empty, param2 = System.Guid.Empty }
    );
    

提交回复
热议问题