gpt4 book ai didi

asp.net-mvc - seo 的 asp.net mvc url 自定义重写

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:41:03 26 4
gpt4 key购买 nike

我有一些新的 map 路由,但我想更改 url 中的字符串,例如在此映射中:

mysite/News/More/13

routes.MapRoute(
name: "IssueNews",
url: "News/More/{newsId}",
defaults: new
{
controller = "News",
action = "More",
newsId = UrlParameter.Optional
}
);

我想在我的网址中使用新闻标题并将其更改为:

mysite/News/{news title here}

有什么建议吗?

最佳答案

这条路线应该可以工作

    routes.MapRoute(
name: "IssueNewsTitle",
url: "News/newsId/{newsTitle}",
defaults: new
{
controller = "News",
action = "More",
newsTitle= UrlParameter.Optional
}
);

关于asp.net-mvc - seo 的 asp.net mvc url 自定义重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22271411/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com