廣告:
環(huán)境:asp.net mvc2.0 asp.net 3.5 sp1
在我們的ASPNET二級(jí)目錄應(yīng)用中,有時(shí)會(huì)出現(xiàn)一些異常,比如在根目錄的web.config中添加了HttpHandler以及HttpModule(如一些UrlRewiter重寫組件、自己的全局HttpModule等)在二級(jí)目錄運(yùn)行時(shí)就會(huì)提示找不到找不到指定的文件的異常。
解決方法是在根目錄的web.config中針對根路徑通過location配置這些module和handler等, 并且在location設(shè)置允許子目錄重寫,以及是否被子集應(yīng)用程序繼承設(shè)置為false,如下把<system.web> </system.web>包含在<location></location>結(jié)點(diǎn)內(nèi)部:
<configuration>
<location path="." allowOverride="true" inheritInChildApplications="false">
<system.web>
<httpModules>
<add name="UrlRewriteModule"
type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />
</httpModules>
</system.web>
</location>
</configuration>
這樣配置后就不會(huì)影響到我們的子集應(yīng)用程序了,即二級(jí)目錄等
廣告: