Skip Navigation Links
技术文档
·网站建设
·软件使用
·图形设计
·程序开发
·网络应用
·电脑技巧
 
公司介绍
·公司简介
·索仕SRCOS网络应用平台
·索仕网站管理系统
·影视广告制作
·联系我们
 
 

ASP.Net 4.0 对SEO增强:使用MetaDescription,MetaKeywords,RedirectPermanant等

5/20/2010 12:42:13 PM


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

1. MetaDescription, MetaKeywords指定页面的meta 描述和关键字标签
我们可以在aspx文件的Page指令中指定:

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

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

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

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

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

01 protected void Page_Load(object sender, EventArgs e)
02 {
03     //重定向到某个地址
04     Response.RedirectPermanent("http://somedomain/somepath");
05 }
06  
07 protected void Page_Load(object sender, EventArgs e)
08 {
09     //重定向到RoutingUrl
10     Response.RedirectToRoutePermanent(new { controller = "Test", action = "details", id = "2" });
11 }

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

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

将输出

1 <ol id="list">
2  <li><input id="list_0" type="checkbox" name="list$0" value="1" /><label for="list_0">北京</label></li>
3  <li><input id="list_1" type="checkbox" name="list$1" value="2" /><label for="list_1">上海</label></li>
4  <li><input id="list_2" type="checkbox" name="list$2" value="3" /><label for="list_2">天津</label></li>
5  <li><input id="list_3" type="checkbox" name="list$3" value="4" /><label for="list_3">重庆</label></li>
6 </ol>
作者:玉开 来源:博客园
 
 
 
昆明索仕科技开发有限公司 版权所有 Copyright© 2002-2010 Kunming Source Technology Exploitive Co.,LTD. All Rights Reserved.
电话:0871-5627877 业务QQ:163871 联系我们
本站基于:索仕网站信息管理系统建设 版本 2.0.4325