【问题标题】:How to use t4 template in MVC action link如何在 MVC 动作链接中使用 t4 模板
【发布时间】:2014-04-02 13:47:05
【问题描述】:

我正在尝试使用 t4 模板,这样我就不必在操作链接中键入视图名称,但我不知道如何设置。

在我的布局页面中有一个链接:

 <ul class="menu" >
      <li>@Html.ActionLink("Profile", MVC.Profile.Views.Index)</li>
  </ul>

所以我期待它加载:http://localhost:1234/Profile/Index,但它正在加载 http://localhost:1234/Login/~/Views/Profile/Index.cshtml

一些身体可以帮助解决这个问题吗?

默认路线:

 routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Login", action = "Index", id = UrlParameter.Optional }
            );

谢谢

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-routing url-routing t4


    【解决方案1】:

    知道了!

    操作链接代码应为&lt;li&gt;@Html.ActionLink("Profile", MVC.Profile.Index())&lt;/li&gt;

    谢谢

    【讨论】:

      猜你喜欢
      • 2016-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-16
      相关资源
      最近更新 更多