是这样有一个新增的<httpModules>节放到程序根目录web.config中是有效的可用,但这不符合我的要求,我只要其中一个目录下文件有效,我新建一个web.config以下文件,放到一个目录下,并将程序根目录web.config中<httpModules>节注释了。但这样无法可用,请问错在哪里。
web.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<httpModules>
<add name="HttpUploadModule"
type="Krystalware.SlickUpload.HttpUploadModule, Krystalware.SlickUpload" />
</httpModules>
</system.web>
</configuration>
web.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<httpModules>
<add name="HttpUploadModule"
type="Krystalware.SlickUpload.HttpUploadModule, Krystalware.SlickUpload" />
</httpModules>
</system.web>
</configuration>
里,参考http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_aspnetconfig/html/c282a0c3-0642-458b-8426-565ead922749.aspNot valid in application child directories Because they apply to an entire application, the authentication, httpModules, sessionState, and trust configuration elements are excluded from child directories of applications. That is, they are restricted to the Machine.config file and to the Web.config file at the Web site and the application levels only. You can use the allowDefinition attribute to restrict a configuration section to the Web.config file.
建议你在web.config加一个setting设置你需要处理的目录,在你的httpModule检查这个setting,然后跟当前请求的URL做比较,如果符合条件就处理,否则不处理
<!-- 使用location-->
<location path="admin">
<system.web>
<authorization>
<deny users="?" />
</authorization>
<!--<sessionState mode="Off"
cookieless="true" />-->
</system.web>
</location>
</configuration>
看了明白了
<!-- application specific settings --> <appSettings>
<add key="FoldersToApply" value="dir1,dir2,dir3" />
</appSettings> <system.web>
...
</system.web>
</configuration>