Asp.Net4.0/VS2010新变化(4):SEO的改进

时间:2022-04-23
本文章向大家介绍Asp.Net4.0/VS2010新变化(4):SEO的改进,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

asp.net4.0的webform中,对于Page对象新增加了二个属性:MetaKeywords,MetaDescription 

后端代码上,写法也更简单,以前可能需要这样写:

this.Header.Controls.AddAt(0, new HtmlMeta() { Name = "keywords", Content = Website.MetaKeyword });//关键字
this.Header.Controls.AddAt(1, new HtmlMeta() { Name = "Description", Content = Website.MetaDescription });//关键字描述       

现在可以直接这样写:

this.Page.MetaKeywords = "Asp.Net4.0";
this.Page.MetaDescription = "Asp.Net 4.0中新增了MetaKeywords与MetaDescription二个属性";

另外上一篇提到的"webform中也可以直接url路由"也算是一种对SEO的改进,

最后asp.net4.0中新增了Response.RedirectPermanent(string url)来取代Response.Redirect(string url)方法,用于将原来发送的"http 302"变成"http 301",这样据说对搜索引擎更友好(通俗的讲就是原来的Redirect重定向,并不会诱导搜索引擎顺着你的意思抓到新页面,而新的方法可以),类似的还有Response.RedirectToRoutePermanent(string routeName)方法