天天看點

.NET ASP.NET 僞靜态

僞靜态配置

1. 引用UrlRewriter.dll元件(bin檔案夾)

2.配置web.config

(1)在configuration節點下添加如下代碼(死的):

<configSections>
    <section name="CustomConfiguration" type="URLRewriter.Config.UrlsSection, URLRewriter"/>
</configSections>
           

如圖:

.NET ASP.NET 僞靜态

(2)配置URL規則(活的,供借鑒):

<CustomConfiguration>
    <urls>
      <add virtualUrl="([^-]+).html" destinationUrl="$1.aspx" /><!--沒有參數-->
      <add virtualUrl="([^-]+)-([^-]*).html" destinationUrl="$1.aspx?key1=$2" /><!--一個參數-->
      <add virtualUrl="([^-]+)-([^-]*)-([^-]*).html" destinationUrl="$1.aspx?key1