通过 Url.Action 在 Web API 控制器中创建 MVC Link
Creating an MVC Link through Url.Action Inside a Web API Controller
我正在尝试通过 Url.Action 在我的 Web API Controller
中创建一个 MVC link
string scheme = Request.RequestUri.Scheme;
System.Web.Mvc.UrlHelper helper = new System.Web.Mvc.UrlHelper();
string linkBackUrl = helper.Action("TestAction", "TestController", new{ code=code1, code2 = code2}, scheme);
我在 linkBackUrl:
行收到错误(调试时)
试图读取或写入受保护的内存。这通常表明其他内存已损坏。
是否有另一种方法可以在 Web API 控制器中创建 linkBackUrl?
我认为这就是您要找的东西:
string linkBackUrl = Url.Action("TestAction", "TestController", new { code = code1, code2 = code2 });
或者您认为:
<button onclick="window.history.back();">Go Back</button>
我正在尝试通过 Url.Action 在我的 Web API Controller
中创建一个 MVC linkstring scheme = Request.RequestUri.Scheme;
System.Web.Mvc.UrlHelper helper = new System.Web.Mvc.UrlHelper();
string linkBackUrl = helper.Action("TestAction", "TestController", new{ code=code1, code2 = code2}, scheme);
我在 linkBackUrl:
行收到错误(调试时)试图读取或写入受保护的内存。这通常表明其他内存已损坏。
是否有另一种方法可以在 Web API 控制器中创建 linkBackUrl?
我认为这就是您要找的东西:
string linkBackUrl = Url.Action("TestAction", "TestController", new { code = code1, code2 = code2 });
或者您认为:
<button onclick="window.history.back();">Go Back</button>