繁体   English   中英

asp mvc使用参数创建seo友好URL

[英]asp mvc create seo friendly URL with parameter

我正在尝试创建seo友好的url。

当前网址:

http://www.example.com/Product/free-mobile-images/Mobile

预期输出:

http://www.example.com/Product/free-mobile-images/

我正在使用id从数据库中获取moblie数据。

动作方法

public ActionResult Product(string seotext, string id)
{

return View();

}

Route.config

routes.MapRoute(
                "Product",
                "Product/{seotext}/{id}",
                new { controller = "Home", action = "Product" });

我试图从路线值中删除暴民:

 RouteData.Values.Remove("id");
 RouteData.Values.Remove("Mobile");

但是我仍然在URL末尾得到/ Mobile。

让我知道我做错了什么,任何帮助都会很棒。

为什么不只是创建一个文件夹结构来模仿所需的路径,然后调用文件Index.aspx,它会产生相同的效果,但要简单得多。

例如,一个名为Product的文件夹,然后在其中名为free-mobile-images的文件夹,然后是名为index.aspx的文件

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM