简体   繁体   English

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

[英]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.

相关问题 如何在MVC4中的@ Url.Action中传递querystring值 - How to pass querystring value in @Url.Action in MVC4 如何在MVC中的@ Url.Action内部应用动态控制器名称 - How to apply dynamic controller name inside @Url.Action in MVC 如何在同一控制器中获得MVC4 Web API以支持HTTP动词和“操作”方法? - How do I get MVC4 Web API to support HTTP Verbs and “Action” methods in the same controller? 如何使用 Z02A3A357710CC2A5DDFFB74ED012FB59Z.Action 到达 controller 并生成 url - How to use Url.Action to get to the controller and also generate the url 如何将Url.Action链接到特定的控制器方法 - How to link Url.Action to a specific controller method Url.Action无法调用控制器方法 - Url.Action fails to call controller method 网址操作未达到控制器方法 - Url.Action not hitting controller method 如何正确使用 Url.Action() 在 MVC 中显示图像? - How do I use Url.Action() appropriately to display an image in MVC? @ Url.Action(“ Action”,“ Controller”)调用具有相同名称的post和get方法 - @Url.Action(“Action”,“Controller”) calls both post and get method with same name 在MVC4中,如何使用Url中的参数从控制器动作重定向到视图? - In MVC4, how to redirect to a view from a controller action with parameters in the Url?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM