草庐IT

ActionLink

全部标签

c# - 如何为此 ActionLink 创建正确的路由值?

SearchResults.aspx的模型是PersonSearch的实例;当新页面的请求到达时(GET请求),操作方法应该接受它并计算新结果。[AcceptVerbs(HttpVerbs.Get)]publicActionResultSearchResults(PersonSearchsearch,int?page){ViewData["Results"]=newPaginatedList(_searchService.FindPersons(search),page??0,1);returnView("SearchResults",search);}然后我必须生成上一个/下一个链接

c# - 如何在 ASP.NET MVC 4 区域中正确使用 Html.ActionLink

我最近发现了AreasinASP.NETMVC4,我已经成功实现了,但是我在RazorView中遇到了@Html.ActionLink助手的问题。这个助手生成的URL似乎总是相对于当前页面的URL。我在IIS7(Win7)中将我的网站配置为位于/Foo的应用程序虚拟目录。我注册了两个区域:管理和博客。我在AdminAreaRegistration.cs和BlogsAreaRegistration.cs文件中有默认代码。我将namespaces=new[]{"MvcProject.Controllers"}添加到默认RouteConfig的默认值中:publicclassRouteCon

c# - 无法动态调度 Html.ActionLink

我对MVC3有疑问我正在尝试使用@Html.ActionLink()为我的博客项目中的标题生成一个链接。在ActionLink中使用常量字符串效果很好,但如果我使用Posts.Title(循环当前Post模型的标题),我会得到这个异常:CS1973:'System.Web.Mvc.HtmlHelper'hasnoapplicablemethodnamed'ActionLink'butappearstohaveanextensionmethodbythatname.Extensionmethodscannotbedynamicallydispatched.Considercastingt

c# - asp.net MVC3 Razor : display actionlink based on user role

我是MVC的新手。我希望能够为某些用户隐藏一些操作链接。假设我有一个“创建”操作链接,我只希望管理员看到并单击它。我想使用asp.net中可用的某种“loggedintemplate”,但它似乎在razor中不起作用。我可以使用某种带有if语句的代码块来检查当前用户及其角色,但这可能不是最佳做法?我的index.cshtml..//wantsomeadminauthattributehere...@Html.ActionLink("CreateNew","Create")我的Controller..//GET:/Speaker/Create[Authorize(Roles="Admin