UrlRewritingNet.UrlRewrite 中文文档

Installation of UrlRewritingNet.UrlRewrite
安装UrlRewritingNet.UrlRewrite
System requirements 
系统要求
UrlRewritingNet.UrlRewrite is running on each Web server which is running ASP.NET 2.0.
UrlRewritingNet.UrlRewrite 可以在任何一个运行asp.Net 2.0的web服务器上运行。 
Tested Web server with UrlRewritingNet.UrlRewrite:
被UrlRewritingNet.UrlRewrite测试过web服务器:
   IIS 5.0
   IIS 5.1
   IIS 6.0
   Visual Studio 2005 WebDev Server
   IIS 5.0
   IIS 5.1
   IIS 6.0
   Visual Studio 2005 WebDev Server
We didn't test it with Mono.
Installation
To install UrlRewritingNet.UrlRewrite you have to follow these easy steps:

1.  Installation of the Assembly  ".dll"
2.  Installation of the configuration schema 
3.  Setting up the configuration settings area in the Web.config 
4.  Embedding UrlRewritingNet as Http Module  
安装
为了安装UrlRewritingNet.UrlRewrite,你不得不按照下面几个简单的步骤:
1.“.dll”组件的安装。
2.配置模式的安装。
3.在web.config中设置配置。
4.将UrlRewritingNet作为Http Module嵌入。
Installation of the Assembly 
Just copy UrlRewritingNet.UrlRewriter.dll in your web applications /bin folder. 
安装组件
只需要拷贝UrlRewritingNet.UrlRewriter.dll在你的web应用程序/Bin目录。
Installation of the configuration schema 
To get IntelliSense support just copy the file urlwritingnet.xsd in you web application (wherever you want). If you web application is part of a solution, you can also put the file anywhere in the solution. 
配置模式的安装
为了得到智能提示的支持,只需要拷贝urlwritingnet.xsd文件到你的web应用程序中(无论什么位置)。如果你的web应用程序是解决方案的一部分,你也可以把这个文件放在解决方案中的任何一个地方。
Setting up the configuration settings area in the Web.config 
To get the configuration settings from the web.config this area has to be advertised. Just replace the <configSections> if exists.
在web.config中设置配置
为了从web.config中得到配置设置,这个区域必须被告知。如果<configSections>存在则替换它。
<configuration> 
  <configSections> 
    <section name="urlrewritingnet"   
             restartOnExternalChanges="true" 
             requirePermission ="false"  
             type="UrlRewritingNet.Configuration.UrlRewriteSection, 
                   UrlRewritingNet.UrlRewriter"  /> 
  </configSections> 
</configuration>
If the area is advertised, just create it.
如果这个区域被占用,就创建它。
  <urlrewritingnet 
      xmlns="http://www.urlrewriting.net/schemas/config/2006/07" > 
  </urlrewritingnet> 
This section has to be placed in <configuration /> but after <configSections />. Do not place this in <appSettings /> or <system.web>! Fo example se the sample web application. To get IntelliSense  support you have to add "xmlns" attribute.
这部分不需安置在<configuration />的内部<configSections />之后。不要安置在<appSettings />或者<system.web>中!例如示例web应用程序.为了得到智能提示支持,你不得不添加"xmlns"属性。
Embedding UrlRewritingNet as HttpModul 
To handle all incoming requests with UrlRewritingNet you have to register the component as Http Module in the <system.web /> section in Web.config. 
将UrlRewritingNet作为Http Module嵌入
用UrlRewritingNet处理所有的链入请求,你不得不在<system.web />片段中将组件注册成为Http Module。
<system.web> 
    <httpModules> 
     <add name="UrlRewriteModule" 
         type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" /> 
    </httpModules>     
  </system.web> 
Now UrlRewritingNet configuration is complete.
现在UrlRewritingNet配置完毕。
Necessary changes by upgrading from 1.1 to 2.0 
By upgrading from 1.1 to 2.0 you have to change a little bit on your existing configuration. 
1.  All rules need a unique name. 
2.  Don't use the attribute "compileRegEx" anymore.
3.  Refresh configuration schema 
If one of these requirements is not given, the application throws exceptions. 
从1.1升级到2.0需要做的一些改变
从1.1升级到2.0你不得不改变一些已经存在的配置。
1.所有的规则都需要独一无二的name.
2.不要再使用"compileRegEx" 属性。
3.刷新配置模式。
如果其中一条要求没有满足,则程序会抛出异常。
Give your rules unique names 
All existing (and of course new) rules have to get unique names. This is necessary to change them on runtime. 
Old rule entry: 
      <add virtualUrl="^~/girls/(.*)/(.*).aspx"             
           rewriteUrlParameter="ExcludeFromClientQueryString"  
           destinationUrl="~/Default.aspx?name=$1&amp;show=$2" 
           ignoreCase="true" /> 
New rule entry: 
      <add name="Gallery"   
           virtualUrl="^~/girls/(.*)/(.*).aspx"             
           rewriteUrlParameter="ExcludeFromClientQueryString"  
           destinationUrl="~/Default.aspx?name=$1&amp;show=$2" 
           ignoreCase="true" /> 
给你的规则添加独一无二的名字。
所有存在的规则都需要一个独一无二的名字。这个些改变是让他们运行环境所必要的。
旧规则: 
      <add virtualUrl="^~/girls/(.*)/(.*).aspx"             
           rewriteUrlParameter="ExcludeFromClientQueryString"  
           destinationUrl="~/Default.aspx?name=$1&amp;show=$2" 
           ignoreCase="true" /> 
新规则: 
      <add name="Gallery"   
           virtualUrl="^~/girls/(.*)/(.*).aspx"             
           rewriteUrlParameter="ExcludeFromClientQueryString"  
           destinationUrl="~/Default.aspx?name=$1&amp;show=$2" 
           ignoreCase="true" />
Remove "compileRegEx" attribute 
The attribute "compileRegEx" has been obsolete. So please remove it from all entries and the <urlrewritingnet />  configuration area. 
移除"compileRegEx"属性
"compileRegEx"属性已经废除。所以请将它从所有的<urlrewritingnet />配置区域内移除。
Refresh configuration schema 
For getting IntelliSense support you have to update the namespace to the current version. 
  <urlrewritingnet 
    xmlns="http://www.urlrewriting.net/schemas/config/2006/07" > 
And of course you have to replace the existing urlrewritingnet.xsd with the new one.
刷新配置模式
为了得到智能提示,你不得不更新namespace(命名空间)而得到正确的版本。
<urlrewritingnet 
    xmlns="http://www.urlrewriting.net/schemas/config/2006/07" > 
并且你当然可以用一个新的urlrewritingnet.xsd替换已经存在的这个文件。
Configuration 
von UrlRewritingNet.UrlRewrite is configured in the area in Web.config which you set up during the 
installation (see page 8). 
Here a little sample: 
  <urlrewritingnet 
    rewriteOnlyVirtualUrls="true"    
    contextItemsPrefix="QueryString"  
    defaultPage = "default.aspx" 
    xmlns="http://www.urlrewriting.net/schemas/config/2006/07" > 
    <providers> 
      <add name="MyGreatProvider" type="MyApp.Web.MyGreatProvider, 
MyGreatProvider.dll"/> 
    </providers> 
    <rewrites> 
      <add name="Rule1"  virtualUrl="^~/(.*)/Detail(.*).aspx"             
           rewriteUrlParameter="ExcludeFromClientQueryString"  
           destinationUrl="~/Default.aspx?language=$1&amp;id=$2" 
           ignoreCase="true" /> 
      <add name="Rule2"   
           provider="MyGreatProvider" 
           myattribute="/foo/bar/dhin.aspx"  
           rewriteUrlParameter="ExcludeFromClientQueryString"  
           rewrite="Domain"  
           ignoreCase="true" /> 
    </rewrites> 
  </urlrewritingnet> 
This configuration can become very comprehensive, so you can swap it out into an external config file. 
Please use the configSource attribute for that: 
  <urlrewritingnet configSource="ExternalRewrite.config" /> 
In ExternalRewrite.config you have to put the complete configuration area. 
配置
UrlRewritingNet.UrlRewrite家族已经被我们配置在上一节所说的web.config文件中。
这儿有一个简单的例子:
<urlrewritingnet 
    rewriteOnlyVirtualUrls="true"    
    contextItemsPrefix="QueryString"  
    defaultPage = "default.aspx" 
    xmlns="http://www.urlrewriting.net/schemas/config/2006/07" > 
    <providers> 
      <add name="MyGreatProvider" type="MyApp.Web.MyGreatProvider, 
MyGreatProvider.dll"/> 
    </providers> 
    <rewrites> 
      <add name="Rule1"  virtualUrl="^~/(.*)/Detail(.*).aspx"             
           rewriteUrlParameter="ExcludeFromClientQueryString"  
           destinationUrl="~/Default.aspx?language=$1&amp;id=$2" 
           ignoreCase="true" /> 
      <add name="Rule2"   
           provider="MyGreatProvider" 
           myattribute="/foo/bar/dhin.aspx"  
           rewriteUrlParameter="ExcludeFromClientQueryString"  
           rewrite="Domain"  
           ignoreCase="true" /> 
    </rewrites> 
  </urlrewritingnet>
这个配置文件已经非常全面了。所以,你可以将这段安置在你的扩展config文件中。
请使用configSource(配置源)属性:
<urlrewritingnet configSource="ExternalRewrite.config" />
在 ExternalRewrite.config你不得不使用全部的配置。
Attributes for <urlrewritingnet /> 
rewriteOnlyVirtualUrls 
                        true, false (Standard: true) 
                        Prevents rewriting for real existing files on the server if true. 
contextItemsPrefix 
                        String 
                        If the Query String parameters should putted down in                                                       HttpContext.Current.Items[], you can define a prefix, which will be                                     inserted  before the parameters name with a point after.  
defaultProvider 
                        ProviderName (Standard: RegEx) 
                        Name of the default Rewrite Provider used if no other is assigned.
defaultPage 
                        Dateiname 
                        Name of the default page which is used on access without file extension                             (see page 6, working without file extension). 
<urlrewritingnet /> 属性
rewriteOnlyVirtualUrls 
                        true, false (Standard: true) 
                        如果为真则防止重写真实存在的文件。 
contextItemsPrefix 
                        String 
                        假设这个请求字符参数被写入在HttpContext.Current.Items[]中,                                            你可以定义一个前缀,以"."结尾插入在这个参数的前面 
defaultProvider 
                        ProviderName (默认: RegEx) 
                        如果没有其他的指派,这个名字将用默认的重写驱动。
defaultPage 
                        Dateiname 
                        用于存取没有扩展名的默认页面名称(见6页, 无扩展名工作).
The  <providers /> listing 
Here can the custom providers be added. Fore more information see "Page 19" Embedding the provider in the web.config" and the documentation of the specific provider.
<providers />列表
自定义的providers(驱动)添加。更多信息见19页"在web.config文件中嵌入驱动"和特别provider(驱动)文档。
The <rewrites /> listing 
Here can the rewrite rules be added. The rules are processed from up to down, the first matching rule is used for the rewriting and the process is being ready (no more rule will be processed). 
To add a new rule just type a new <add /> element, IntelliSense will present you the available attributes which are listed below. 
name 
Name of the rule 
                        A free selectable name of the rule which has to be unique. With this name                         (ID) you can 
                        do some magic with this rule programmatically, too (see page 16) 
provider 
ProviderName
                        Name of the used provider. If no one is selected, the default provider will                             be  used. 
redirect 
                        None, Application, Domain (Standard: None) 
                        To make a redirect instead of a rewrite. 
None    Normal rewrite 
Application   Redirect within your web application 
Domain   Redirect to another domain which has to be part of                                             the destinationUrl 
redirectMode
Permanent, Temporary (Standard: Temporary) 
                        Here you can select of which type your redirect is  permanent (HTTP status                         code 301) or temporary (HTTP status code 302). If you want to transfer a                         website from one
rewrite 
Application, Domain (Standard: Application) 
                        Defines whether the domain has to be included in the process or not. 
rewriteUrlParameter 
ExcludeFromClientQueryString,
                        StoreInContextItems ,
                        IncludeQueryStringForRewrite 

                        (Standard: ExcludeFromClientQueryString) 
ExluceFromClientQueryString
In Request.QueryString[] 
all parameters are available. In                                                     Page.ClientQueryString are only the parameters added, which are visible in                         the browsers address field, so a postback is possible. Parameters added in                         destinationUrl are not added in Page.ClientQueryString.
StoreInContextItems 
                        All parameters listed in the Url field of the browser and the parameters from                         the rewrite are added in HttpContext.Current.Items[] too, prefixed by a                             string defined in contextItemsPrefix. 
IncludeQueryStringForRewrite 
                        Include the full Query String (the parameters in the browsers address field)                         in the rewrite process, so that they can be handled by the engine. 

As a developer of a rewrite provider you should look to develop your provider meeting the standard behavior, but of course  it can vary. 
<rewrites />列表
在这里添加重写规则。规则被从上到下的处理,第一条匹配的规则将被处理并且加入处理队列(其他规则将不被处理)。
加入一条新规则只需要添加<add />元素标签。智能提示将为你呈现下面列出的有效属性。
name 
规则的名称 
                        一个可以自由选择的但是必须唯一的名字,使用这个名字(ID)你也可以通过具有编程                        性的规则做一些变化(见16页) 
provider 
ProviderName(驱动名称) 
                        Name of the used provider. If no one is selected, the default provider will                             be  used. 
redirect 
                        None, Application, Domain (Standard: None) 
                        设置一个跳转代替重写。 
None    普通重写
Application   在你的web应用程序中跳转。 
Domain   跳转到另外一个必须包含目标Url的域名上。 
redirectMode
Permanent(永久), Temporary(暂时) (默认: Temporary) 
                        这里,你可以选择你的跳转类型为永久(HTTP 状态代码301)或者暂时(HTTP状态代码302)。如果你想从另外一个网站迁移。
rewrite 
Application(应用程序), Domain(域名) (默认: Application) 
                        定义域名是否必须包含在进程中。 
rewriteUrlParameter 
ExcludeFromClientQueryString,
                        StoreInContextItems ,
                        IncludeQueryStringForRewrite 

                        (默认: ExcludeFromClientQueryString) 
ExluceFromClientQueryString
In Request.QueryString[] 
所有的参数都是有效的,只有在浏览器地址栏看到的                             Page.ClientQueryString 参数被添加的时候,  PostBack 才会有效。参数加在                                dstinationUrl 而不是添加在Page.ClientQueryString.
StoreInContextItems 
                        所有的参数被罗列在浏览器的url和重写规则HttpContext.Current.Items[]参数中,                        这些被预定义在contextItemPrefix字符串中。
IncludeQueryStringForRewrite 
                        在重写队列中包含所有的查询字符串(在浏览器Url地址栏里的参数)所以你可以使用引                        擎(UrlRewritingNet.UrlRewrite)处理它们。
作为一个重写驱动的开发者,你应该使得你开发的驱动能够符合标准的行为,当然,也可以有不同。

RegEx Rewrite Attributes 
Our standard provider has the following attributes. 
virtualUrl 
                        regular expression 
                        A regular expression which is used for replacing the current Url with                                     destinationUrl. 
destinationUrl 
                        regular expression replacement term 
                        A regular expression term describing the target page (physical file). 
regexOptions
                        Multiline, ExplicitCapture, Singleline, IgnorePatternWhitespace, RightToLeft, 
                        ECMAScript, CultureInvariant 
                        For an optimal control over the regular expressions you can add additional                         to ignoreCase here some RegexOptions. But this is only necessary in special                         cases. For more information see the Microsoft MSDN documentation. 
属性:正则重写
我们标准的驱动支持下列属性:
virtualUrl 
                        正则表达式 
                        一条用于替换真实Url的最终Url正则表达式。
destinationUrl 

                        正则表达式替换的区域限制 
                        一条正则表达式限制描述的目标页面(物理文件)
regexOptions
                        多行模式,明确的抓取,单行,忽略空格,从右到左,ECMAScript,CultureInvariant 
                        为了得到最佳的通过正则控制的设置,你也可以添加附加的忽略正则选项。但是这只适                        合特别需要的地方。更多的信息见MSND文档。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值