如何从mvc4中的新文件夹中调用控制器

时间:2017-03-21 12:17:00

标签: asp.net-mvc-4

当Controller位于:

时,如何通过锚标记调用控制器

区域 - > Ticket-> TicketController

以下是代码:

 <a href="@Url.Action("TicketTemplate", "MyTickets", new {area = string.Empty,controller = "TicketTemplate", page = Model.PageNumber, sort = "DateCreated ", isAsc = isAsc })">
                        Date Created
                        <span class="@clsDateCreated" style="text-align: right;"></span>
                    </a>

以上代码无效.. 我如何调用控制器? 这是路径:

~/Areas/Ticket/Controllers/TicketTemplateController.cs

1 个答案:

答案 0 :(得分:1)

你可以这样做,它会起作用,但我不知道是否有更好的解决方案。

<a href="@Url.Action("MyTickets", "Ticket/TicketTemplate", , new {area = string.Empty,controller = "TicketTemplate", page = Model.PageNumber, sort = "DateCreated ", isAsc = isAsc })">
    Date Created
   <span class="@clsDateCreated" style="text-align: right;"></span>
</a>