标签:
重写前:http://localhost:13275/Default.aspx?username=wilson
重写后:http://localhost:13275/wilson
<browsers>
<browser refID="Default">
<controlAdapters>
<adapter controlType="System.Web.UI.HtmlControls.HtmlForm"
adapterType="URLRewriter.Form.FormRewriterControlAdapter"/>
</controlAdapters>
</browser>
</browsers>
PS: refID:不可以与ID和arentID同时存在
<configSections>
<section name="CustomConfiguration" type="URLRewriter.Config.UrlsSection, URLRewriter"/>
</configSections>
<CustomConfiguration>
<urls>
<!--([\w]+)表示,1到n个字母或数字或下划线或汉字组成-->
<add virtualUrl="~/([\w]+)*" destinationUrl="~/Default.aspx?username=$1"/>
</urls>
</CustomConfiguration>
<httpModules>
<add type="URLRewriter.RewriterModule, URLRewriter" name="RewriterModule"/>
</httpModules>
if (!IsPostBack)
{
StringBuilder sb = new StringBuilder();
sb.Append("当前所在位置:Default.aspx<br/>");
if (!string.IsNullOrEmpty(Request.Params["username"]))
{
sb.Append("所接收到的参数username:" + Request.Params["username"]);
}
Response.Write(sb.ToString());
}
.NET4.0下web应用程序用UrlRewriter.dll重写无后缀路径
标签:
原文地址:http://www.cnblogs.com/gougoustar/p/4318760.html