ASP.NET MVC Routing two GUIDs

前端 未结 2 1832
生来不讨喜
生来不讨喜 2021-02-10 06:35

I have an action taking two GUIDs:

public class MyActionController : Controller
{
  //...

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


        
2条回答
  •  别那么骄傲
    2021-02-10 07:32

    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 }
    );
    

提交回复
热议问题