.net 将字符串添加到请求的URL

.net 将字符串添加到请求的URL,.net,asp.net-mvc,seo,.net,Asp.net Mvc,Seo,我建立了一条路线,比如在访问时返回特定的博客条目 看起来像这样 www.mywebsite.com/100 然而,我希望在返回页面时,我也将博客标题添加到URL中 例如,用户可以输入上述url,但当他返回页面时,url必须如下所示: www.mywebsite.com/100/My-Blog-Title http://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-an-uns

我建立了一条路线,比如在访问时返回特定的博客条目 看起来像这样

www.mywebsite.com/100
然而,我希望在返回页面时,我也将博客标题添加到URL中 例如,用户可以输入上述url,但当他返回页面时,url必须如下所示:

www.mywebsite.com/100/My-Blog-Title
http://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-an-unsorted-array
就像Stakoverflow上发生的那样: 我输入这个URL

http://stackoverflow.com/questions/11227809/
收到请求后,URL如下所示:

www.mywebsite.com/100/My-Blog-Title
http://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-an-unsorted-array
如何在我的MVC项目中实现这一点?谁能帮忙吗

同时,请对
SEO
友好性进行评论,同时建议您首选的方法


谢谢

这似乎是一个简单的重定向。请参见

您可以使用JavaScript来实现它

返回存储在某个JavaScript变量中的博客标题

var blogTitle = "My-Blog-Title"

阅读博客标题并阅读此内容以更改url而不重定向。

如果您在Chrome开发者工具中打开网络选项卡并加载此问题的地址(仅id)(
http://stackoverflow.com/questions/21005768/
),您将看到返回一个
http301
响应-一个永久重定向到友好url(
http://stackoverflow.com/questions/21005768/add-string-to-the-requested-url/

要在ASP.NET MVC中对此作出响应,请执行以下操作:

public ActionResult GetThingy(int id)
{
    var title = GetTitle(id);
    return RedirectPermanent(Url.Action("GetThingy", new { id = id, title = title} );
}
这将重定向到控制器上的另一个操作,如:

public ActionResult GetThingy(int id, string title)
{
    //do your thing here
}
请查看此链接: