ASP.NET裡,URL重寫的方法設定偽靜態(測試成功)

來源:互聯網
上載者:User

本文來自此路徑( http://www.w17x.com/AritcleDisplay.aspx?id=768 )在此僅做個人存檔

 

網上很多配置的方法,不過我很多都沒有設定成功,這次這個是成功了,大家可以直接使用

方法正如:

<?xml version="1.0"?>

<configuration>
  <configSections>
  <section name="rewriter"
           requirePermission="false"
           type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
  </configSections>

  <appSettings/>
<connectionStrings/>

<system.web>
  <httpModules>
      <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
    </httpModules>

  </system.web>
  <system.webServer>

    <modules runAllManagedModulesForAllRequests="true">
      <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
    </modules>

    <validation validateIntegratedModeConfiguration="false" />

  </system.webServer>
  <rewriter>
    <rewrite url="pageName_([0-9]{1,})\.aspx" to="default.aspx?id=$1" />
    <rewrite url="pageName_([0-9]{1,})_([0-9]{1,})\.aspx" to="default.aspx?id=$1&amp;page=$2" />
  </rewriter>

</configuration>

另外,如果你要把偽靜態配置成HTML這樣的尾碼,那除了把配置規則裡的ASPX改成HTML,還要設定IIS。

IIS設定的方法:
internet資訊服務-->找到你共用的目錄-->右鍵點擊屬性 -->點擊'配置'-->
映射下面 -->找到.aspx的可執行檔路徑 複製路徑-->粘貼路徑-->副檔名為".html"-->然後把檢查檔案是否存在的勾去掉

這樣就可以了

BIN裡的DLL檔案到附件下載。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.