2010-11-02 102 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