首页 新闻 会员 周边

如何写一个自定义的Module?

0
悬赏园豆:20 [已解决问题] 解决于 2015-03-30 17:19

需求:

对于静态文件的处理:

  当访问的是静态文件时,使用系统的StaticFileModule

  当范根的是静态目录时:

      如果有默认文件,响应默认文件(使用系统的DefaultFileModule)

      如果没有默认文件,则执行自定义的Module。

 

以下方案无效:

<configuration>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="false">
      <remove name="FormsAuthentication" />
      <add name="DirectoryToFileModule" type="Zupo.Lifenxiang.UI.Web.Infrastructure.DirectoryModule, Zupo.Lifenxiang.UI.Web" />
    </modules>
    <handlers>
      <clear/>
      <add name="staticfile" path="*" verb="*" resourceType="Either" requireAccess="Read" modules="StaticFileModule,DefaultDocumentModule,DirectoryToFileModule"
          preCondition="" />
      <add name="nostaticfile" path="*" verb="GET"
           type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <defaultDocument enabled="true">
      <files>
        <clear/>
        <add value="__default__.jpg" />
        <add value="__default__.png" />
        <add value="__default__.bmp" />
      </files>
    </defaultDocument>
  </system.webServer>
  <system.web>

  </system.web>
</configuration>

参考:

        <globalModules>
            <add name="UriCacheModule" image="%windir%\System32\inetsrv\cachuri.dll" />
            <add name="FileCacheModule" image="%windir%\System32\inetsrv\cachfile.dll" />
            <add name="TokenCacheModule" image="%windir%\System32\inetsrv\cachtokn.dll" />
            <add name="HttpCacheModule" image="%windir%\System32\inetsrv\cachhttp.dll" />
            <add name="StaticCompressionModule" image="%windir%\System32\inetsrv\compstat.dll" />
            <add name="DefaultDocumentModule" image="%windir%\System32\inetsrv\defdoc.dll" />
            <add name="DirectoryListingModule" image="%windir%\System32\inetsrv\dirlist.dll" />
            <add name="ProtocolSupportModule" image="%windir%\System32\inetsrv\protsup.dll" />
            <add name="StaticFileModule" image="%windir%\System32\inetsrv\static.dll" />
            <add name="AnonymousAuthenticationModule" image="%windir%\System32\inetsrv\authanon.dll" />
            <add name="RequestFilteringModule" image="%windir%\System32\inetsrv\modrqflt.dll" />
            <add name="CustomErrorModule" image="%windir%\System32\inetsrv\custerr.dll" />
            <add name="HttpLoggingModule" image="%windir%\System32\inetsrv\loghttp.dll" />
            <add name="RequestMonitorModule" image="%windir%\System32\inetsrv\iisreqs.dll" />
            <add name="IsapiModule" image="%windir%\System32\inetsrv\isapi.dll" />
            <add name="IsapiFilterModule" image="%windir%\System32\inetsrv\filter.dll" />
            <add name="ManagedEngine64" image="%windir%\Microsoft.NET\Framework64\v2.0.50727\webengine.dll" preCondition="integratedMode,runtimeVersionv2.0,bitness64" />
            <add name="ManagedEngine" image="%windir%\Microsoft.NET\Framework\v2.0.50727\webengine.dll" preCondition="integratedMode,runtimeVersionv2.0,bitness32" />
            <add name="ConfigurationValidationModule" image="%windir%\System32\inetsrv\validcfg.dll" />
            <add name="iisnode" image="C:\Program Files\iisnode\iisnode.dll" preCondition="bitness64" />
            <add name="ManagedEngineV4.0_32bit" image="%windir%\Microsoft.NET\Framework\v4.0.30319\webengine4.dll" preCondition="integratedMode,runtimeVersionv4.0,bitness32" />
            <add name="ManagedEngineV4.0_64bit" image="%windir%\Microsoft.NET\Framework64\v4.0.30319\webengine4.dll" preCondition="integratedMode,runtimeVersionv4.0,bitness64" />
        </globalModules>
519740105的主页 519740105 | 大侠五级 | 园豆:5810
提问于:2015-03-14 15:44
< >
分享
最佳答案
0
519740105 | 大侠五级 |园豆:5810 | 2015-03-30 17:19
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册