如何获取MVC4 Url.Action方法以在控制器之前包含哈希

时间:2015-07-10 13:28:51

标签: c# .net asp.net-mvc-4

目前我有这个

<script type="text/javascript">
    Globalize.culture("pt-BR");
</script>

它会返回Url.Action("action", "controller", new { area = "", otherParam=""});

我希望它在主机之后使用哈希返回:<host>/controller/action?params

1 个答案:

答案 0 :(得分:1)

扩展到Url Helper:

    public static string ActionWithPrefix(this UrlHelper url, string action, string controller, object routeValues)
    {
          return Regex.Replace(url.Action(action, controller, routeValues), @"(/[^/]*/)", @"$1#/");
    }

将返回<AppVirDir>/#/controller/action?params