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"/>

  • 相关阅读:
    Java中如何动态创建接口的实现
    使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
    MyBatis中的@Mapper注解及配套注解使用详解(上)
    SpringMVC-DispatcherServlet工作流程及web.xml配置
    SpringMVC-DispatcherServlet配置(Spring-servlet.xml)
    Spring MVC 配置文件dispatcher-servlet.xml 文件详解
    python3 UnicodeEncodeError: 'gbk' codec can't encode character 'xa0' in position 30: illegal multibyte sequence
    python3之日期和时间(转载)
    python3 操作sqlSever
    python 抓取alexa数据
  • 原文地址:https://www.cnblogs.com/tangself/p/1706099.html
Copyright © 2011-2022 走看看