urlメモ
5218 ワード
一、http://www.urlrewriter.net/でコンポーネントをダウンロードする
二、説明に従ってwebを配置する.config
三、IISを配置して、/******/************形式をサポートさせる
四、コードを入れて、ページファイル名がformに現れないようにする
プロジェクトに「App_BrowsersForm.browser」を追加し、次のコードを書き込みます.
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:
This enables the URL Rewriter to read its configuration from the rewriteRules node in the web.config file.
5. Add UrlRewriter mapper HttpModule: This enables the URL Rewriter to intercept web requests and rewrite URL requests.
6. Add some rules to your web.config file:
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をファイルに書き込む
<セクションに追加
二、説明に従ってwebを配置する.config
三、IISを配置して、/******/************形式をサポートさせる
四、コードを入れて、ページファイル名がformに現れないようにする
プロジェクトに「App_BrowsersForm.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:
This enables the URL Rewriter to read its configuration from the rewriteRules node in the web.config file.
5. Add UrlRewriter mapper HttpModule:
6. Add some rules to your web.config file:
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をファイルに書き込む
<