这是基于对类似问题的答案here。
我的代码如下:
string url = Url.Action("Details", "Home", new RouteValueDictionary(new { Area = "MyArea", id = Id }), HttpContext.Request.Url.Scheme, HttpContext.Request.Url.Authority);
但是,生成的url包含如下所示的双端口号:
http://localhost:54383:54383/MyArea/Home/Details/1
网址应为:
http://localhost:54383/MyArea/Home/Details/1
答案 0 :(得分:3)
尝试一下就可以了
string url = Url.Action("Details", "Home", new { Area = "MyArea", id = Id }, HttpContext.Request.Url.Scheme);