.Net编程 net
当前位置:首页 > 网站建设专题 > .Net编程
ASP.Net 4.0 对SEO增强一:使用MetaDescription,MetaKeywords,RedirectPermanant等
发布日期:2010-07-24 阅读次数:2353 字体大小:

    现在的网站对SEO越来越重视,有很多公司在做seo优化;换句话说SEO可以给网站主带来利益,做好了SEO,不需要付广告费就可以从搜索引擎带来更多的流量。鉴于此Asp.Net4.0对seo方面做了一些优化工作。

1. MetaDescription, MetaKeywords指定页面的meta 描述和关键字标签

我们可以在aspx文件的Page指令中指定:

以下为引用的内容:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="OutputCacheTest.Default"
 MetaDescription="我是页面描述"
 MetaKeywords="关键字1,关键字2"%>

也可以在cs文件中指定,例如:

以下为引用的内容:

protected void Page_Load(object sender, EventArgs e)
{
    MetaDescription = "this is a test";
    MetaKeywords = "Asp.net 4.0,Cache";
}

2. 使用Response.RedirectPermanent告诉搜索引擎当前地址已经永久重定向了

在HttpResponse中新添加了RedirectPermanant方法和RedirectToRoutePermanent方法,这两个方法都可以实现301重定向,用来告诉搜素引擎当前访问的内容已经永久的移动到了另一个地址,这在程序改版修改了url规则时非常有用,使用举例如下:

以下为引用的内容:

protected void Page_Load(object sender, EventArgs e)
{
    //重定向到某个地址
    Response.RedirectPermanent("http://somedomain/somepath");
}

protected void Page_Load(object sender, EventArgs e)
{
    //重定向到RoutingUrl
    Response.RedirectToRoutePermanent(new { controller = "Test", action = "details", id = "2" });
}

3. 在.Net 4.0中RadioButtonList和CheckBoxList服务器端控件都支持用ul或ol标签做输出,例如

以下为引用的内容:

<asp:CheckBoxList runat="server" ID="list" RepeatLayout="OrderedList">
    <asp:ListItem Value="1">北京</asp:ListItem>
    <asp:ListItem Value="2">上海</asp:ListItem>
    <asp:ListItem Value="3">天津</asp:ListItem>
    <asp:ListItem Value="4">重庆</asp:ListItem>
</asp:CheckBoxList>

将输出

以下为引用的内容:

<ol id="list">
 <li><input id="list_0" type="checkbox" name="list$0" value="1" /><label for="list_0">北京</label></li>
 <li><input id="list_1" type="checkbox" name="list$1" value="2" /><label for="list_1">上海</label></li>
 <li><input id="list_2" type="checkbox" name="list$2" value="3" /><label for="list_2">天津</label></li>
 <li><input id="list_3" type="checkbox" name="list$3" value="4" /><label for="list_3">重庆</label></li>
</ol>

    原文地址:http://www.cnblogs.com/yukaizhao/archive/2010/05/18/asp_net_40_seo_enhancement_new_feature