zoukankan      html  css  js  c++  java
  • url 备忘录

    一、在http://www.urlrewriter.net/下载组件

    二、按说明配置web.config

    三、配置IIS,让其支持/**********/********形式

    四、加入代码,让页文件名不在form中出现

    在项目中加入“App_Browsers\Form.browser”,在里面写入如下代码:

    <browsers>
      <browser refID="Default">
        <controlAdapters>
          <adapter controlType="System.Web.UI.HtmlControls.HtmlForm"
                   adapterType="命名空间.FormRewriterControlAdapter" />
        </controlAdapters>
      </browser>
    </browsers>

    FormRewriterControlAdapter.cs文件内容

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Web;
    using System.Web.UI;
    namespace DataCenter
    {
        public class FormRewriterControlAdapter : System.Web.UI.Adapters.ControlAdapter
        {
            protected override void Render(HtmlTextWriter writer)
            {
                base.Render(new RewriteFormHtmlTextWriter(writer));
            }
        }

        public class RewriteFormHtmlTextWriter : HtmlTextWriter
        {
            public RewriteFormHtmlTextWriter(HtmlTextWriter writer)
                : base(writer)
            { InnerWriter = writer.InnerWriter; }


            public RewriteFormHtmlTextWriter(System.IO.TextWriter writer)
                : base(writer)
            { InnerWriter = writer; }

            public override void WriteAttribute(string name, string value, bool fEncode)
            {
                if ((name == "action"))
                {
                    HttpContext Context = HttpContext.Current;
                    if (Context.Items["ActionAlreadyWritten"] == null)
                    {
                        value = Context.Request.RawUrl; Context.Items["ActionAlreadyWritten"] = true;
                    }
                }
                base.WriteAttribute(name, value, fEncode);
            }
        }
    }


    操作方法:IIS站点属性 ->主目录 ->  配置




    点击插入按键

    Installation
    ============
    1. Open your web project, or create a new one.
    2. Add a reference to the Intelligencia.UrlRewriter assembly.
    3. Open the web.config file.
    4. Add Configuration section handler:
     
       <configSections>
      <section
       name="rewriter"
       requirePermission="false"
       type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
     </configSections>

     This enables the URL Rewriter to read its configuration from the rewriteRules node in the
     web.config file.

    5. Add UrlRewriter mapper HttpModule:
     
     <system.web>
      <httpModules>
       <add
        type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"
        name="UrlRewriter" />
      </httpModules>
     </system.web>
     
     This enables the URL Rewriter to intercept web requests and rewrite URL requests.

    6. Add some rules to your web.config file:

     <rewriter>
      <if url="/tags/(.+)" rewrite="/tagcloud.aspx?tag=$1" />
      <!-- same thing as <rewrite url="/tags/(.+)" to="/tagcloud.aspx?tag=$1" /> -->
     </rewriter>

     The syntax of the rewriter section is very powerful.  Refer to the help file for more details
     of what is possible.  The above rule assumes you have mapped all requests to the .NET runtime.
     For more information on how to do this, see http://urlrewriter.net/index.php/using/installation/

    7. Compile and test!

    8.把rewriter 写入一个文件

    在< <appSettings>>节上面加入

     <rewriter file="/App_Data/Rewriter.xml"/>

  • 相关阅读:
    MySql常用日期时间查询
    微信开发中网页授权access_token与基础支持的access_token异同
    Sqlserver复杂查询
    Array排序和List排序
    关于java按位操作运算
    验证redis的快照和AOF
    线程安全 加锁机制
    Redis 与 数据库处理数据的两种模式
    redis实现点击量/浏览量
    jsp网站访问次数统计的几种方法
  • 原文地址:https://www.cnblogs.com/tangself/p/1706099.html
Copyright © 2011-2022 走看看