[英]How do I get MVC4 Url.Action method to include a hash before the controller
Currently I have this 目前我有这个
Url.Action("action", "controller", new { area = "", otherParam=""});
Which returns <host>/controller/action?params
as it should. 哪个会返回<host>/controller/action?params
。
I want it to return with a hash after the host like this: <host>/#/controller/action?params
我希望它在主机之后像这样返回一个散列: <host>/#/controller/action?params
Extension to Url Helper: 扩展到网址助手:
public static string ActionWithPrefix(this UrlHelper url, string action, string controller, object routeValues)
{
return Regex.Replace(url.Action(action, controller, routeValues), @"(/[^/]*/)", @"$1#/");
}
that will return <AppVirDir>/#/controller/action?params
这将返回<AppVirDir>/#/controller/action?params
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.