62,254
社区成员
发帖
与我相关
我的任务
分享
<configuration>
<!-- 手动添加 -->
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
</configSections>
<!-- 手动添加 -->
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/web/new/(.[\d]*).html</LookFor>
<SendTo>~/web/new.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/web/new/(.[\w]*)/(.[\w]*).html</LookFor>
<SendTo><![CDATA[~/web/new.aspx?id=$1&name=$2]]></SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
protected void btnClick_Click(object sender, EventArgs e)
{
string id = "asdsd";
string name = "123";
Response.Redirect("~/web/new/" + id + "/"+name+".html");
}
protected void Button1_Click(object sender, EventArgs e)
{
int id = 1;
Response.Redirect("~/web/new/" + id + ".html");
}
protected void Button2_Click(object sender, EventArgs e)
{
string id = "xiaoyunchao";
string name = "111";
}
<?xml version="1.0"?>
<!--
注意: 除了手动编辑此文件以外,您还可以使用
Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
“网站”->“Asp.Net 配置”选项。
设置和注释的完整列表在
machine.config.comments 中,该文件通常位于
\Windows\Microsoft.Net\Framework\v2.x\Config 中
-->
<configuration>
<!-- 手动添加 -->
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
</configSections>
<!-- 手动添加 -->
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/web/new/(.[\d]*).html</LookFor>
<SendTo>~/web/new.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/web/new/(.[\w]*)/(.[\w]*).html</LookFor>
<SendTo><![CDATA[~/web/new.aspx?id=$1&name=$2]]></SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
<httpModules>
<add name="ModuleRewriter" type="URLRewriter.ModuleRewriter, URLRewriter"/>
</httpModules>
</system.web>
</configuration>