使用paginatin时生成url的ASP.NET MVC错误 [英] ASP.NET MVC bug with generation url when using paginatin

查看:58
本文介绍了使用paginatin时生成url的ASP.NET MVC错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须接受

 [HttpGet] 
[路线(" {forumName}",Order = 8)]
[Route(" {forumName} / Page / {page}",Order = 7)]
[OutputCache(Duration = 30,VaryByParam =" forumName; page",Location = OutputCacheLocation.ServerAndClient )]
公共异步任务< ActionResult> ShowForum(string forumName,int page = 1)


 [HttpGet] 
[RefreshDetectFilter]
[Block(VisibleBlock = false) ]
[路线("〜/论坛/ {forum} / {topicName}",订单= 6)]
[路线(&〜/ Forums / {forum} / {topicName} / Page / {page}",Order = 5)]
[OutputCache(Duration = 30,VaryByParam =" topicName; page",Location = OutputCacheLocation.ServerAndClient)]
public async Task< ActionResult> ShowTopic(字符串论坛,字符串topicName,int page = 1)

我从

获取网址

< a href =" @ Url.Action(" ShowForum"," Forums",new {forumName = Model.NameTranslit})" title =" @ Model.Name"> @ Model.Name< / a> 

 < a href =" @ Url.Action(" ShowTopic"," Forums",new {forum = Model.CurrentForumTranslite,topicName = Model.TitleTranslite})"标题= QUOT; @ Model.Title"> @ Model.Title< / A> 

当我在页面上有这样的


/论坛/测试/ Page / 2


链接到子论坛我有正常的链接,但链接到我的主题


/论坛/ Test / Test_Topic / Page / 2


但应该是


/论坛/ Test / Test_Topic


我的理解。我有这个错误,因为在我的操作中我有相同的页面路由参数


我该怎么做才能解决这个问题?

解决方案

MVC位于以下链接。


http://forums.asp.net/1146.aspx/1?MVC


I have to acion

    [HttpGet]
    [Route("{forumName}", Order = 8)]
    [Route("{forumName}/Page/{page}", Order = 7)]
    [OutputCache(Duration = 30, VaryByParam = "forumName;page", Location = OutputCacheLocation.ServerAndClient)]
    public async Task<ActionResult> ShowForum(string forumName, int page = 1)

    [HttpGet]
    [RefreshDetectFilter]
    [Block(VisibleBlock = false)]
    [Route("~/Forums/{forum}/{topicName}", Order = 6)]
    [Route("~/Forums/{forum}/{topicName}/Page/{page}", Order = 5)]
    [OutputCache(Duration = 30, VaryByParam = "topicName;page", Location = OutputCacheLocation.ServerAndClient)]
    public async Task<ActionResult> ShowTopic(string forum, string topicName, int page = 1)

I get url from

 <a href="@Url.Action("ShowForum", "Forums", new {forumName = Model.NameTranslit})" title="@Model.Name">@Model.Name</a>

and

<a href="@Url.Action("ShowTopic", "Forums", new { forum = Model.CurrentForumTranslite, topicName = Model.TitleTranslite })" title="@Model.Title">@Model.Title</a>

When I at page with like this

/Forums/Test/Page/2

Link to the sub forum I have normal link, but link to the topic I have with page

/Forums/Test/Test_Topic/Page/2

But should be

/Forums/Test/Test_Topic

How I understand. I have this bug because in my actions I have the same route parameter for page

What I should to do to fix that?

解决方案

MVC is at the link below.

http://forums.asp.net/1146.aspx/1?MVC


这篇关于使用paginatin时生成url的ASP.NET MVC错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆