熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

偽靜態web.config配置步驟

2022-06-13   來源: .NET編程 

  復制代碼 代碼如下:

  <?xml version= encoding=UTF?>
<configuration>
<!第一步注冊url重寫模塊放到webconfig的最上部>
<configSections>
<section name=RewriterConfig type=URLRewriterConfigRewriterConfigSerializerSectionHandler URLRewriter />
</configSections>
<!第二步添加重寫規則>
<RewriterConfig>
<!先制定全部重寫規則內容>
<Rules>
<!制定每個單獨頁面的規則>
<RewriterRule>
<!原始請求地址>
<SendTo><![CDATA[~/newsaspx?id=$&pid=$]]></SendTo>
<!重寫後的地址>
<LookFor>~/news/([]*)/([\d]*)l</LookFor>
</RewriterRule>
<RewriterRule>
<!原始請求地址>
<SendTo><![CDATA[~/productaspx?pid=$]]></SendTo>
<!重寫後的地址>
<LookFor>~/product/([\d]*)\zangdalei</LookFor>
</RewriterRule>
</Rules>
</RewriterConfig>
<systemweb>
<compilation debug=false targetFramework=>
<!第四部url重寫防止真實的頁面也被重寫如果網站中真實存在頁面需要添加編譯指令不編譯真實的html文件>
<buildProviders>
<add extension=l type=SystemWebCompilationPageBuildProvider />
</buildProviders>
</compilation>
<!第三部url重寫 將用戶的請求頁面交給相應的處理程序注意請求的後綴名格式>
<httpHandlers>
<add verb=* path=l type=URLRewriterRewriterFactoryHandler URLRewriter />
<add verb=* path=*zangdalei type=URLRewriterRewriterFactoryHandler URLRewriter />
</httpHandlers>
</systemweb>
<systemwebServer>
<handlers>
<add name=aspnethtml path=l verb=GETPOST modules=IsapiModule scriptProcessor=C:\Windows\MicrosoftNET\Framework\v\aspnet_isapidll resourceType=Unspecified preCondition=classicModeruntimeVersionvbitness />
<add name=aspnetzangdalei path=*zangdalei verb=GETPOST modules=IsapiModule scriptProcessor=C:\Windows\MicrosoftNET\Framework\v\aspnet_isapidll resourceType=Unspecified preCondition=classicModeruntimeVersionvbitness />
</handlers>
<defaultDocument>
<files>
<clear />
<add value=defaultaspx />
<add value=l />
</files>
</defaultDocument>
</systemwebServer>
</configuration>


From:http://tw.wingwit.com/Article/program/net/201404/30519.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.