扩展名的搜索引擎友好的使用Asp.net web表单 [英] Extensionless SEO Friendly with Asp.net webforms

查看:99
本文介绍了扩展名的搜索引擎友好的使用Asp.net web表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何越来越得到扩展而无需asp.net web表单查询字符串搜索引擎友好的URL。

How to get extension less and without query string SEO friendly URL for asp.net web forms.?

推荐答案

我已经找到了一个很好的文章的在这里

I have found out a very good article Here

这是一个非常好的博客文章写了关于如何重定向包含查询字符串作为扩展少SEO友好的URL。

It is a very good blog post written on how to redirect urls which contain query strings as extension less seo friendly urls.

通过包含的Global.asax到应用程序做的一种方法。

One method of doing it by including Global.asax into the application.

下面是该例子

包含的Global.asax到应用程序中。

Include Global.asax into the application.

<%@ Import Namespace="System.Web.Routing" %>

Global.asax文件里面

inside global.asax file

void registerroute(RouteCollection routes)
    {
        routes.MapPageRoute(
            "Home-Route",
            "Home",
            "~/Default.aspx"
            );
}

这将映射主页或默认页面

Which will map the home page or default page

有关查询字符串的URL如 http://xyz.com/page.aspx?id=about

For Query string urls like http://xyz.com/page.aspx?id=about

routes.MapPageRoute(
          "Page-Route",
          "Pages/{page}",
          "~/page.aspx"
          ); 

然后调用这个registerroute()内的应用程序启动事件的Global.asax在

Then call this registerroute() inside application start event under Global.asax

 void Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup
        registerroute(RouteTable.Routes);
    }

然后进入内页的查询字符串。

Then to access the query string inside pages.

string pg = Page.RouteData.Values["page"] as string;

这篇关于扩展名的搜索引擎友好的使用Asp.net web表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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