2010-11-02 106 views
1

我不知道我做了什麼,但突然我的腳本和內容文件夾爲所有項目返回404。MVC2 - 內容和腳本文件夾返回404

我想也許這是文件夾權限,因爲我把項目放在「我的文檔」下的文件夾中。我以管理員身份運行VS,並且我仍然遇到該風格的問題。

我在調試模式下運行,沒有彈出錯誤。

我的母版頁沒有任何變化。我試圖把它一件一件地拉開,沒有這樣的運氣。

當我導航到任何圖像/ css /腳本我得到一個404錯誤。爲了證明我不瘋狂,這裏是我的路線。

#region Error Friendly Names 
       routes.MapRoute(
         "AccessDenied",            // Route name 
         "Error/AccessDenied",       // URL with parameters 
         new { controller = "Error", action = "Index", code = "403" } // Parameter defaults 
        ); 
       routes.MapRoute(
         "NotFound",            // Route name 
         "Error/NotFound",       // URL with parameters 
         new { controller = "Error", action = "Index", code = "404" } // Parameter defaults 
        ); 
       routes.MapRoute(
         "ServerError",            // Route name 
         "Error/ServerError",       // URL with parameters 
         new { controller = "Error", action = "Index", code = "500" } // Parameter defaults 
        ); 
       #endregion 

       #region Redirection 
       routes.MapRoute(
       "Redirection", // Route name 
       "Redirect/{id}", // URL with parameters 
       new { controller = "Redirect", action = "Index", id = UrlParameter.Optional } // Parameter defaults 
       ); 
       #endregion 

       routes.MapRoute(
       "Default", // Route name 
       "{controller}/{action}/{id}", // URL with parameters 
       new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults 
       ); 

       //handle all unknown routes with a 404 
       routes.MapRoute(
        "TheOneRouteToRuleThemAll",          // Route name 
        "{*path}",              // URL with parameters 
        new { controller = "Error", action = "Index", id = UrlParameter.Optional, code = "404" } // Parameter defaults 
       ); 

在你對我的最後一條路線稱呼犯規之前,那是之前的情況,當它工作的很好。我還刪除了它作爲測試,看看它是否是它,它不是罪魁禍首。

就好像內容和腳本的MVC內部處理已停止工作。

這裏是我的頭部分

<head><title>My Site</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="robots" content="index, follow" /><meta name="keywords" /><meta name="title" /><meta name="description" /><link href="/Content/style.css" rel="stylesheet" type="text/css" /><link href="/Content/Themes/Green/Green.css" rel="stylesheet" type="text/css" /><link href="/Content/prettyPhoto.css" rel="stylesheet" type="text/css" /> 


    <!--[if IE 7]> 

    <style>ul#servicesbox li {height: 1%;width: 70px;}</style> 

    <![endif]--> 

    <!--[if IE 6 ]> 

    <link href="/Content/ie.css" rel="stylesheet" type="text/css" /> 

    <![endif]--> 

<script src="/Scripts/jquery.js" type="text/javascript" /><script src="/Scripts/ddsmoothmenu.js" type="text/javascript" /><script src="/Scripts/cufon-yui.js" type="text/javascript" /><script src="/Scripts/Fonts/fontin.js" type="text/javascript" /><script src="/Scripts/functions.js" type="text/javascript" /><script src="/Scripts/jcarousellite_1.0.1c4.js" type="text/javascript" /><script src="/Scripts/jquery.prettyPhoto.js" type="text/javascript" /> 

    <!-- PNG transparency fix for IE 6 --> 

    <!--[if IE 6]> 

    <script src="/Scripts/pngfix.js" type="text/javascript" /> 

    <script>DD_belatedPNG.fix('#logo img,#slider,#piecemaker_slider,#contentbar,#testibox,#servicesbox li img,.nivo-controlNav a,.nivo-directionNav a,#social-links a img');</script> 

    <![endif]--> 

    <script type="text/javascript"> 

     $(function() { 

      $(".newsticker-jcarousellite").jCarouselLite({ 

       btnPrev: null, 

       btnNext: null, 

       btnGo: null, 

       mouseWheel: false, 

       easing: null, 

       vertical: true, 

       hoverPause: true, 

       circular: true, 

       visible: 1, 

       start: 0, 

       scroll: 1, 

       auto: 4000, 

       speed: 1000, 

       beforeStart: null, 

       afterEnd: null 

      }); 

     }); 

</script> 

</head> 

任何想法?

+0

您使用的是VS開發Web服務器還是IIS? – dotariel 2010-11-02 16:12:05

+0

我正在使用VS開發服務器。 – Josh 2010-11-02 16:12:23

+0

我也在2臺機器上試過這個 - 它以前都是在這兩個機器上工作的。 – Josh 2010-11-02 16:13:25

回答

2

我開始拉的web.config出來的塊,我發現這節:

<httpHandlers> 
      <add verb="*" path="*" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     </httpHandlers> 

時我刪除了它,它又開始工作了。當我試圖讓應用程序在IIS6中運行時,我認爲它被粘貼了。

1

也許與此有關:?

//handle all unknown routes with a 404 
      routes.MapRoute(
       "TheOneRouteToRuleThemAll",          // Route name 
       "{*path}",              // URL with parameters 
       new { controller = "Error", action = "Index", id = UrlParameter.Optional, code = "404" } // Parameter defaults 
      ); 

註釋掉和測試。編輯: 我的不好。 OP表示他已經嘗試評論TheOneRouteToRuleThemAll。

您是否嘗試過爲您的靜態文件設置一些忽略?

routes.IgnoreRoute("{file}.js"); 
routes.IgnoreRoute("{file}.html"); 

它看起來像下面的路線可能會映射到您的靜態位置

routes.MapRoute(
      "Default", // Route name 
      "{controller}/{action}/{id}", // URL with parameters 
      new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults 
      ); 
+0

正如我在我的帖子中所說的,事實並非如此。我做了評論和測試。我也在其他項目中使用了很長時間,沒有不良影響。 – Josh 2010-11-02 16:11:58

+0

重讀後編輯答案 – TimC 2010-11-02 17:28:55

+0

我嘗試添加忽略路由,它仍然顯示404。默認映射是標準的,我沒有內容控制器。 – Josh 2010-11-02 18:03:49