2011-04-15 127 views
8

ASP.NETアプリケーションとIIS7の開発マシンでルーティングルールを作成しましたが、すべて正常に動作します。私もIIS7を持っているprodサーバーにソリューションを展開すると、URLにアクセス中にエラー404(ページが見つかりません)が表示されます。多分誰かがどこに問題があるのか​​を指摘することができますか?ルーティングHTTPエラー404.0 0x80070002

実際のエラー

HTTPエラー404.0 - あなたが探している リソースが が削除されましたが見つかりませんでしたが、その名前が変更され、または が一時的に利用できませんでした。詳細 エラーInformationModule IISのWebコア 通知MapRequestHandler ハンドラStaticFileエラーコード 0x80070002が要求されたURL http://xxx.xxx.xxx.xxx:80/pdf-button 物理パス C:\ WWW \ pathtoproject \ PDF-ボタンログオン 方法匿名ログオンユーザー匿名

私の実際コード

 <add key="RoutePages" value="all,-forum/"/> 

      UrlRewrite.Init(ConfigurationManager.AppSettings["RoutePages"]); 


    public static class UrlRewrite 
    { 
      public static void Init(string routePages) 
      { 

       _routePages = routePages.ToLower().Split(new[] { ',' }); 
       RegisterRoute(RouteTable.Routes); 




      } 

      static void RegisterRoute(RouteCollection routes) 
      { 

       routes.Ignore("{resource}.axd/{*pathInfo}"); 
       routes.Ignore("favicon.ico"); 
       foreach (string routePages in _routePages) 
       { 
        if (routePages == "all") 
         routes.MapPageRoute(routePages, "{filename}", "~/{filename}.aspx"); 
        else 
         if (routePages.StartsWith("-")) 
          routes.Ignore(routePages.Replace("-", "")); 
         else 
         { 
          var routePagesNoExt = routePages.Replace(".aspx", ""); 
          routes.MapPageRoute(routePagesNoExt, routePagesNoExt, string.Format("~/{0}.aspx", routePagesNoExt)); 
         } 
       } 

      } 
} 
+0

どのようなルーティングを使用しましたか? MVC? –

+0

System.Web.Routing.RouteCollectionクラス(.NET 4.0)を使用します – Tomas

+0

- pdf-button.aspxにルーティングすることを期待していますか?私はあなたが実現したと確信している0x80070002 = ERROR_FILE_NOT_FOUND – Rup

答えて

23

web.configファイルに以下の行を追加する必要があることが判明しました。 Prodサーバーにも。

<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" > 
     <remove name="UrlRoutingModule"/>  
    </modules> 
    </system.webServer> 
+0

runAllManagedModulesForAllRequests = "true"だけで仕事をしたが、Robert Bethgeによって与えられた解決策も良い。 –

2

私のソリューションは、すべて試した後:

悪い展開を、古いPrecompiledApp.configは私の配備場所の周りにぶら下がって、すべてが動作しませ作っていました。

働いていた私の最終設定:

  • は7.5、Win2k8r2 x64の、
  • 統合モードのアプリケーションプールのweb.configで
  • 何も変化IIS - これはルーティングのための特別なハンドラがないことを意味します。他の多くの記事が参考にしているセクションの私のスナップショットです。 PassthroughRouteHandler

  • (任意のノートの唯一の方法)

    void Application_Start(object sender, EventArgs e) { 
        // Register routes... 
        System.Web.Routing.Route echoRoute = new System.Web.Routing.Route(
          "{*message}", 
         //the default value for the message 
          new System.Web.Routing.RouteValueDictionary() { { "message", "" } }, 
         //any regular expression restrictions (i.e. @"[^\d].{4,}" means "does not start with number, at least 4 chars 
          new System.Web.Routing.RouteValueDictionary() { { "message", @"[^\d].{4,}" } }, 
          new TestRoute.Handlers.PassthroughRouteHandler() 
         ); 
    
        System.Web.Routing.RouteTable.Routes.Add(echoRoute); 
    } 
    
  • :私はFluorineFXを使用していますので、私はそのハンドラが追加されているけど、私は他のものを必要としませんでした:

    <system.web> 
        <compilation debug="true" targetFramework="4.0" /> 
        <authentication mode="None"/> 
    
        <pages validateRequest="false" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/> 
        <httpRuntime requestPathInvalidCharacters=""/> 
    
        <httpModules> 
        <add name="FluorineGateway" type="FluorineFx.FluorineGateway, FluorineFx"/> 
        </httpModules> 
    </system.web> 
        <system.webServer> 
        <!-- Modules for IIS 7.0 Integrated mode --> 
        <modules> 
         <add name="FluorineGateway" type="FluorineFx.FluorineGateway, FluorineFx" /> 
        </modules> 
    
        <!-- Disable detection of IIS 6.0/Classic mode ASP.NET configuration --> 
        <validation validateIntegratedModeConfiguration="false" /> 
        </system.webServer> 
    
  • Global.ashx

    public class PassthroughRouteHandler : IRouteHandler { 
    
        public IHttpHandler GetHttpHandler(RequestContext requestContext) { 
         HttpContext.Current.Items["IncomingMessage"] = requestContext.RouteData.Values["message"]; 
         requestContext.HttpContext.Response.Redirect("#" + HttpContext.Current.Items["IncomingMessage"], true); 
         return null; 
        } 
    } 
    
: - の.csこれは、次いで、Default.aspxのによって処理されるhttp://andrew.arace.info/#stackoverflowからhttp://andrew.arace.info/stackoverflowから自動変換を達成しました
+0

PrecompiledApp.config情報で私の日を保存しました。 :-) どうもありがとう。 – ekimpl

0

Windowsエクスプローラでこれをオフにします。

「既知の型は表示ファイルの種類の拡張子は」

8

は解決策は、

<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" > 
    <remove name="UrlRoutingModule"/>  
    </modules> 
</system.webServer> 

作品を提案しますが、パフォーマンスが低下する可能性があり、現在登録されているすべてのHTTPモジュールは、リクエストごとに実行されるためにも、エラーが発生することがあります管理されたリクエスト(例:.aspx)だけではありません。彼のための

<system.webServer> 
    <modules> 
    <remove name="UrlRoutingModule-4.0" /> 
    <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" /> 
    </modules> 
</system.webServer> 

クレジットは、コリンに行く:これは、モジュールは、より賢明な解決策は、あなたのweb.configファイルでこれを含めることです、すべての.jpg .GIFの.css .htmlをPDFファイルなどに

を実行することを意味しますファーこのトピックに関する投稿をhttp://www.britishdeveloper.co.uk/2010/06/dont-use-modules-runallmanagedmodulesfo.htmlにチェックアウトしてください。

1

私の問題は、System.Web.Routingがバージョン3.5で、web.configがバージョン4.0.0.0を要求した新しいサーバーでした。 解像度が

%のWINDIR%\ Frameworkの\ v4.0.30319 \ます。aspnet_regiis -i

%のWINDIR Global.asax.csでこれを持つ%\ Framework64 \ v4.0.30319 \ます。aspnet_regiis -i

0

ました私のためにそれを解決した。

protected void Application_Start() 
     { 
      AreaRegistration.RegisterAllAreas(); 
      RouteConfig.RegisterRoutes(RouteTable.Routes); 
     } 
関連する問題