zoukankan      html  css  js  c++  java
  • ASP.Net 4.0 对SEO增强一:使用MetaDescription,MetaKeywords,RedirectPermanant等

    现在的网站对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>
    

    Asp.net 新特性相关阅读:

    1. 从页面标记<%%>说起
    2. Asp.Net 4.0 中可以用自定义的Provider做OutputCache 了
    3. SEO增强支持MetaKeywords,和MetaDescription,RedirectPermanant
    4. SEO增强之URL Routing
    5. 输出更纯净的Html代码,ViewStateMode和ClientIDMode,CheckBoxList等

  • 相关阅读:
    在小程序中实现 Mixins 方案
    watch监听(数组或者对象)
    --socket---网络通信---
    requests实战之破解百度翻译
    nmap命令
    selenium模块的基本使用
    谷歌无头浏览器+反检测
    模拟登录QQ空间
    动作链和iframe的处理
    selenium其他自动化操作
  • 原文地址:https://www.cnblogs.com/yukaizhao/p/asp_net_40_seo_enhancement_new_feature.html
Copyright © 2011-2022 走看看