
ascx文件可以进行url重写规划吗
1个回答
2016-05-30
展开全部
URL重写可以通过编程的方式来实现:
1、在asp.net项目中引入程序集URLRewriter,即在网站的Bin文件夹中添加URLRewriter.dll。
2、在web.config中的configuration节点下添加URLRewriter的配置。
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
</configSections>
注意:configSections必须是configuration节点下的第一个子元素。
3、在web.config中的system.web节点下添加URLRewriter的配置。
<httpModules>
<add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter"/>
</httpModules>
4、在web.config中的configuration节点下配置url重写的规则。
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/article/(\d+)/</LookFor>
<SendTo>~/article_info.aspx?articleId=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
url重写规则说明:
(1)、<RewriterRule>可出现多次,每个重写规则都需要添加一个<RewriterRule>节点。
(2)、在获得匹配<LookFor>节点的url后,转向到相应的<SendTo>节点的url。
(3)、<LookFor>中可使用正则表达式来表示参数。路径转向后,<SendTo>节点中的占位符$1将会用<LookFor>节点中正则表达式所匹配的参数来替换。
(4)、<SendTo>配置中的url占位符可出现多个,如:$2、$3,占位符将按顺序依次由<LookFor>节点中则表达式所匹配的参数来替换。
1、在asp.net项目中引入程序集URLRewriter,即在网站的Bin文件夹中添加URLRewriter.dll。
2、在web.config中的configuration节点下添加URLRewriter的配置。
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>
</configSections>
注意:configSections必须是configuration节点下的第一个子元素。
3、在web.config中的system.web节点下添加URLRewriter的配置。
<httpModules>
<add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter"/>
</httpModules>
4、在web.config中的configuration节点下配置url重写的规则。
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/article/(\d+)/</LookFor>
<SendTo>~/article_info.aspx?articleId=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
url重写规则说明:
(1)、<RewriterRule>可出现多次,每个重写规则都需要添加一个<RewriterRule>节点。
(2)、在获得匹配<LookFor>节点的url后,转向到相应的<SendTo>节点的url。
(3)、<LookFor>中可使用正则表达式来表示参数。路径转向后,<SendTo>节点中的占位符$1将会用<LookFor>节点中正则表达式所匹配的参数来替换。
(4)、<SendTo>配置中的url占位符可出现多个,如:$2、$3,占位符将按顺序依次由<LookFor>节点中则表达式所匹配的参数来替换。

2023-08-29 广告
"StormProxies是全球大数据IP资源服务商,其住宅代理网络由真实的家庭住宅IP组成,可为企业或个人提供满足各种场景的代理产品。点击免费测试(注册即送1G流量)StormProxies有哪些优势?1、IP+端口提取形式,不限带宽,I...
点击进入详情页
本回答由Storm代理提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询