SEO 友好路由 2 个查询字符串

发布于 2025-01-06 05:47:08 字数 536 浏览 2 评论 0原文

我第一次尝试 SEO 友好路由并想传递 2 个查询字符串。

基本路由是www.SiteName.com/brandName,我这样做是

void RegisterRoutes(RouteCollection Routes)
{
    Routes.MapPageRoute("Brands", "Brands/{brand}", "~/Brand.aspx");
}

为了创建一个产品页面,我想传递两个查询字符串,即 www.SiteName.com/brandName/ProductName

为此,我将此行添加到我的路线集合

    Routes.MapPageRoute("Phones", "{*brand}/{*ProdName}", "~/ProdName.aspx");

问题: 产品页面的 SEO 友好路由工作正常,但当我尝试调试时它总是出错......如果我停止调试,它就会再次开始工作。

谁能告诉我如何解决这个问题?

I am trying SEO Friendly Routing first time and wanted to pass 2 query strings.

Basic Routing was www.SiteName.com/brandName which i did like this

void RegisterRoutes(RouteCollection Routes)
{
    Routes.MapPageRoute("Brands", "Brands/{brand}", "~/Brand.aspx");
}

To create a Product page i wanted to pass two query strings i.e.
www.SiteName.com/brandName/ProductName

To do so i added this line to my Route Collection

    Routes.MapPageRoute("Phones", "{*brand}/{*ProdName}", "~/ProdName.aspx");

PROBLEM:
The SEO Friendly Routing for product page is working fine but it always give an error when i try to debug .... if I stop debugging then it starts to work again.

Can anyone please tell me how to fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

银河中√捞星星 2025-01-13 05:47:08

我点击了 msdn 链接,但找不到我做错了什么。

Global.asax

void RegisterRoutes(RouteCollection Routes)
{
    //www.Sitename.com/Brand
    Routes.MapPageRoute("Brands", "Brands/{brand}", "~/Brand.aspx");

    //www.Sitename.com/Brand/Productname
    Routes.MapPageRoute("Phones", "{brand}/{*proname}", "~/product.aspx");

}

Product.aspx.cs

        String ProductName = Page.RouteData.Values["Phones"].ToString();

调试中的错误(Visual Web Dev.2010):
你调用的对象是空的

I followed the msdn link and cant find what i did wrong.

Global.asax

void RegisterRoutes(RouteCollection Routes)
{
    //www.Sitename.com/Brand
    Routes.MapPageRoute("Brands", "Brands/{brand}", "~/Brand.aspx");

    //www.Sitename.com/Brand/Productname
    Routes.MapPageRoute("Phones", "{brand}/{*proname}", "~/product.aspx");

}

Product.aspx.cs

        String ProductName = Page.RouteData.Values["Phones"].ToString();

ERROR in Debugging (Visual Web Dev.2010):
Object Reference not set to an instance of an object

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文