VS2005 URL 重写

shenhui_163 2008-04-08 10:47:09
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<configSections>
<!-- The <configSections> element must contain a <section> tag for the <RewriterConfig> section element.
The type of the section handler is RewriterConfigSerializerSectionHandler, which is responsible for
deserializing the <RewriterConfig> section element into a RewriterConfig instance... -->
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections>

<RewriterConfig>
<Rules>
<!-- Rules for Blog Content Displayer -->
<RewriterRule>
<LookFor>~/(\d{4})/(\d{2})/(\d{2})\.aspx</LookFor>
<SendTo>~/ShowBlogContent.aspx?year=$1&month=$2&day=$3</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/(\d{4})/(\d{2})/Default\.aspx</LookFor>
<SendTo><![CDATA[~/ShowBlogContent.aspx?year=$1&month=$2]]></SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/(\d{4})/Default\.aspx</LookFor>
<SendTo>~/ShowBlogContent.aspx?year=$1</SendTo>
</RewriterRule>


<!-- Rules for Product Lister -->
<RewriterRule>
<LookFor>~/Products/Default\.aspx</LookFor>
<SendTo>~/ListCategories.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Products/Beverages\.aspx</LookFor>
<SendTo>~/ListProductsByCategory.aspx?CategoryID=1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Products/Condiments\.aspx</LookFor>
<SendTo>~/ListProductsByCategory.aspx?CategoryID=2</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Products/Confections\.aspx</LookFor>
<SendTo>~/ListProductsByCategory.aspx?CategoryID=3</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Products/Dairy\.aspx</LookFor>
<SendTo>~/ListProductsByCategory.aspx?CategoryID=4</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Products/GrainsCereals\.aspx</LookFor>
<SendTo>~/ListProductsByCategory.aspx?CategoryID=5</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Products/MeatPoultry\.aspx</LookFor>
<SendTo>~/ListProductsByCategory.aspx?CategoryID=6</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Products/Produce\.aspx</LookFor>
<SendTo>~/ListProductsByCategory.aspx?CategoryID=7</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Products/Seafood\.aspx</LookFor>
<SendTo>~/ListProductsByCategory.aspx?CategoryID=8</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>

<system.web>
<!--*******************************************************************************
Comment either the <httpModules> or <httpHandlers> section to use
URL rewriting... Refer to the article for a discussion on the pros and
cons of each approach...
*******************************************************************************-->
<httpModules>
<add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter" />
</httpModules>

<!--<httpHandlers>
<add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
</httpHandlers>-->
<!--*******************************************************************************-->


<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to enable ASPX debugging. Otherwise, setting this value to
false will improve runtime performance of this application.
Set compilation debug="true" to insert debugging symbols (.pdb information)
into the compiled page. Because this creates a larger file that executes
more slowly, you should set this value to true only when debugging and to
false at all other times. For more information, refer to the documentation about
debugging ASP.NET files.
-->
<compilation
defaultLanguage="c#"
debug="true"
/>

<customErrors
mode="RemoteOnly"
/>

<!-- Forms authentication example -->
<authentication mode="Forms">
<forms name=".MYCOOKIE" loginUrl="Login.aspx" timeout="10"></forms>
</authentication>

<!-- Windows authentication example -->
<!--<authentication mode="Windows" />-->



<!-- AUTHORIZATION
This section sets the authorization policies of the application. You can allow or deny access
to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous
(unauthenticated) users.
-->

<authorization>
<!--<deny users="?" />-->
<!-- For testing with forms authentication... -->
<allow users="*" />
<!-- Allow all users -->


<!-- <allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
</authorization>

<trace
enabled="true"
requestLimit="10"
pageOutput="false"
traceMode="SortByTime"
localOnly="true"
/>

<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>

<!-- GLOBALIZATION
This section sets the globalization settings of the application.
-->
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
/>
</system.web>

<!-- The following <location> elements can be used to test the effect of forms authentication
when performing the URL rewriting at different stages in the lifecycle of the request... -->

</configuration>
...全文
47 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
闲游四疯 2008-04-08
  • 打赏
  • 举报
回复
楼主想表达什么?

62,051

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧