2017-04-13 5 views
1

マイRouteConfig.csHTTPHandlerのASP.NET MVCで5.0

public static class RouteConfig 
    { 
     public static void RegisterRoutes(RouteCollection routes) 
     { 
      routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 
      routes.IgnoreRoute("{*allaspx}", new {allaspx = @".*\.aspx(/.*)?"}); 
      routes.IgnoreRoute("{*allasmx}", new { allasmx = @".*\.asmx(/.*)?" }); 
      routes.IgnoreRoute("{*allsvc}", new { allsvc= @".*\.svc(/.*)?" }); 
      routes.IgnoreRoute("{*allFileAttachments}", new { allattachment = @".*\file.attachment(/.*)?" }); 
      ... 
      ... 
      ... 
     } 
    } 

のWeb.config

<configuration> 
.... 
<system.web> 
<httpHandlers> 
<add path="*.attachment" verb="*" type="MyType, Namespace" /> 
</httpHandlers> 
</system.web> 
<system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <handlers> 
<remove name="attachmentHandler" /> 
     <add name="attachmentHandler" verb="*" path="*.attachment" type="myType, namespace" preCondition="integratedMode" /> 
</handlers> 
... 
</system.webServer> 
... 
</configuration> 

私は、次のURLにアクセスしてみてください、それはまだ、コントローラを見つけようとすると404

で失敗します

http://localhost/somepath/file.attachment?4535345343

答えて

1

これが問題を解決しました。

<system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <handlers> 
    <add name="attachmentHandler" verb="*" 
       path="*.attachment" 
       type="myType, namespace" 
       resourceType="Unspecified" /> 
</handlers> 
... 
</system.webServer> 

参考MSDN - 統合モード

で実行されているIIS 7.0のHTTPハンドラを登録するには
関連する問題