Asp.Net IIS7.5偽靜態設置


注意:先要將應用池設置為集成模式,修改OK后,再改成經典模式。否則,什么托管程序出不來。

1、新建網站,這里不做介紹,很簡單。並把網站設置為集成模式

2、添加通配符腳本映射

打開之后顯示如下界面,在右上角操作欄目內找到“添加通配符腳本映射”這一欄目

我是64位系統就選擇了64位的.net:C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll

是32就選擇32位:C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll


3、添加托管模塊

在右上角操作里選擇添加托管模塊,名稱填寫為all,類型改為 URLRewriter.ModuleRewriter勾選上下面僅針對asp。net應用程序或者是托管程序發出的請求調用:

 

4、網站應用程序池改為經典模式

5、web.config會自動生成以上設置的代碼

    <system.webServer>
        <handlers>
            <add name="all" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv2.0,bitness64" />
        </handlers>
        <modules>
            <add name="all" type="URLRewriter.RewriterModule" preCondition="managedHandler" />
        </modules>
    </system.webServer>

6、下邊是iis6,iis7,iis7.5通用偽靜態代碼

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <!--偽靜態開始-->
    <configSections>
        <section name="CustomConfiguration" type="URLRewriter.Config.UrlsSection, URLRewriter" />
    </configSections>
    <CustomConfiguration>
        <urls>
            <add virtualUrl="~/(\w+).html" destinationUrl="~/ceshi.aspx" />
        </urls>
    </CustomConfiguration>
    <!--偽靜態結束-->
    <system.web>
        <httpRuntime maxRequestLength="2097151" executionTimeout="3600" />
        <globalization requestEncoding="utf-8" responseEncoding="utf-8" fileEncoding="utf-8" />
        <compilation debug="true">
            <assemblies>
                <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            </assemblies>
        </compilation>
        <customErrors mode="Off" defaultRedirect="/404/404.htm"></customErrors>
        <!--偽靜態開始-->
        <httpModules>
            <add type="URLRewriter.RewriterModule, URLRewriter" name="RewriterModule" />
        </httpModules>
        <!--偽靜態結束-->
    </system.web>
    <!--IIS7.0   begin-->
    <system.webServer>
        <handlers>
            <add name="all" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv2.0,bitness64" />
        </handlers>
        <modules>
            <add name="all" type="URLRewriter.RewriterModule" preCondition="managedHandler" />
        </modules>
    </system.webServer>
    <!--IIS7.0   end-->
</configuration>

 

核心注意的地方:先要將應用池設置為集成模式,修改OK后,再改成經典模式。否則,什么托管程序出不來。剩下的按照這個模式操作就可以了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM