目录不存在。参数名称:directoryVirtualPath

时间:2022-05-29 08:06:35

i just published my project to my host on Arvixe and get this error (Works fine local):

我刚刚在Arvixe上向我的主机发布了我的项目,得到了这个错误(在本地运行良好):

Server Error in '/' Application.

Directory does not exist.
Parameter name: directoryVirtualPath

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: Directory does not exist.
Parameter name: directoryVirtualPath

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[ArgumentException: Directory does not exist.
Parameter name: directoryVirtualPath]
   System.Web.Optimization.Bundle.IncludeDirectory(String directoryVirtualPath, String searchPattern, Boolean searchSubdirectories) +357
   System.Web.Optimization.Bundle.Include(String[] virtualPaths) +287
   IconBench.BundleConfig.RegisterBundles(BundleCollection bundles) +75
   IconBench.MvcApplication.Application_Start() +128

[HttpException (0x80004005): Directory does not exist.
Parameter name: directoryVirtualPath]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9160125
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +131
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +194
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +253

[HttpException (0x80004005): Directory does not exist.
Parameter name: directoryVirtualPath]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9079228
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237

What does it mean ?

这是什么意思?

19 个解决方案

#1


210  

I had the same problem and found out that I had some bundles that pointed to non-exisiting files using {version} and * wildcards such as

我也遇到了同样的问题,发现我有一些用{version}和*通配符(如*通配符)指向不存在的文件的包

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
    "~/Scripts/jquery-{version}.js"));

I removed all of those and the error went away.

我把这些都去掉了,误差就消失了。

#2


15  

I had this same issue and it was not a code problem. I was using the publish option (not the FTP one) and Visual Studio was not uploading some of my scripts/css to the azure server because they were not "included in my project". So, locally it worked just fine, because files were there in my hard drive. What solved this issue in my case was "Project > Show all files..." and right click the ones that were not included, include them and publish again

我也有同样的问题,这不是代码问题。我使用的是发布选项(不是FTP选项),Visual Studio没有将我的一些脚本/css上传到azure服务器,因为它们没有“包含在我的项目中”。所以,在本地它运行得很好,因为文件在我的硬盘里。在我的案例中,解决这个问题的是“项目>显示所有文件……”,然后右键单击未包含的文件,包括它们并再次发布

#3


7  

Here's a quick class I wrote to make this easier.

这是我写的一个快速的类,让它更简单。

using System.Web.Hosting;
using System.Web.Optimization;

// a more fault-tolerant bundle that doesn't blow up if the file isn't there
public class BundleRelaxed : Bundle
{
    public BundleRelaxed(string virtualPath)
        : base(virtualPath)
    {
    }

    public new BundleRelaxed IncludeDirectory(string directoryVirtualPath, string searchPattern, bool searchSubdirectories)
    {
        var truePath = HostingEnvironment.MapPath(directoryVirtualPath);
        if (truePath == null) return this;

        var dir = new System.IO.DirectoryInfo(truePath);
        if (!dir.Exists || dir.GetFiles(searchPattern).Length < 1) return this;

        base.IncludeDirectory(directoryVirtualPath, searchPattern);
        return this;
    }

    public new BundleRelaxed IncludeDirectory(string directoryVirtualPath, string searchPattern)
    {
        return IncludeDirectory(directoryVirtualPath, searchPattern, false);
    }
}

To use it, just replace ScriptBundle with BundleRelaxed in your code, as in:

要使用它,只需在代码中使用BundleRelaxed替换ScriptBundle,如下所示:

        bundles.Add(new BundleRelaxed("~/bundles/admin")
            .IncludeDirectory("~/Content/Admin", "*.js")
            .IncludeDirectory("~/Content/Admin/controllers", "*.js")
            .IncludeDirectory("~/Content/Admin/directives", "*.js")
            .IncludeDirectory("~/Content/Admin/services", "*.js")
            );

#4


3  

I ran into the same issue today it is actually I found that some of files under ~/Scripts is not published. The issue is resolved after I published the missing files

我今天遇到了同样的问题,实际上我发现~/Scripts下面的一些文件没有发布。这个问题在我发布丢失的文件之后得到了解决

#5


2  

I also got this error by having non-existant directories in my bundles.config file. Changing this:

通过在包中包含不存在的目录,我也得到了这个错误。配置文件。改变:

<?xml version="1.0"?>
<bundleConfig ignoreIfDebug="true" ignoreIfLocal="true">
    <cssBundles>
        <add bundlePath="~/css/shared">
            <directories>
                <add directoryPath="~/content/" searchPattern="*.css"></add>
            </directories>
        </add>
    </cssBundles>
    <jsBundles>
        <add bundlePath="~/js/shared">
            <directories>
                <add directoryPath="~/scripts/" searchPattern="*.js"></add>
            </directories>
            <!--
            <files>
                <add filePath="~/scripts/jscript1.js"></add>
                <add filePath="~/scripts/jscript2.js"></add>
            </files>
            -->
        </add>
    </jsBundles>
</bundleConfig>

To this:

:

<?xml version="1.0"?>
<bundleConfig ignoreIfDebug="true" ignoreIfLocal="true">
    <cssBundles>
    </cssBundles>
    <jsBundles>
    </jsBundles>
</bundleConfig>

Solve the problem for me.

帮我解决这个问题。

#6


2  

Like @JerSchneid, my problem was empty directories, but my deployment process was different from the OP. I was doing a git-based deploy on Azure (which uses Kudu), and didn't realize that git doesn't include empty directories in the repo. See https://*.com/a/115992/1876622

和@JerSchneid一样,我的问题是空目录,但是我的部署过程与opi不同,我在Azure上做基于gitanjt的部署(使用Kudu),并没有意识到git不包括repo中的空目录。参见https://*.com/a/115992/1876622

So my local folder structure was:

所以我的本地文件夹结构是:

[Project Root]/Content/jquery-plugins // had files

[项目根]/内容/jquery-plugins /有文件

[Project Root]/Scripts/jquery-plugins // had files

[项目根]/脚本/jquery-plugins /有文件

[Project Root]/Scripts/misc-plugins // empty folder

[项目根]/脚本/错误插件/空文件夹

Whereas any clone / pull of my repository on the remote server was not getting said empty directory:

鉴于远程服务器上对我的存储库的任何克隆/拉取都没有得到这个空目录:

[Project Root]/Content/jquery-plugins // had files

[项目根]/内容/jquery-plugins /有文件

[Project Root]/Scripts/jquery-plugins // had files

[项目根]/脚本/jquery-plugins /有文件

The best approach to fixing this is to create a .keep file in the empty directory. See this SO solution: https://*.com/a/21422128/1876622

解决此问题的最佳方法是在空目录中创建.keep文件。请参阅SO解决方案:https://*.com/a/214228/1876622

#7


2  

I had the same issue. the problem in my case was that the script's folder with all the bootstrap/jqueries scripts was not in the wwwroot folder. once I added the script's folder to wwwroot the error went away.

我也有同样的问题。在我的例子中,问题是带有所有引导/jqueries脚本的脚本文件夹不在wwwroot文件夹中。一旦我将脚本的文件夹添加到wwwroot中,错误就消失了。

#8


1  

This may be an old issue.I have similar error and in my case it was Scripts folder hiding in my Models Folder. Stack trace clearly says its missing Directory and by default all Java Scripts should be in Scripts Folder. This may not be applicable to above users.

这可能是个老问题。我也有类似的错误,在我的例子中它是隐藏在我的模型文件夹中的脚本文件夹。堆栈跟踪明确表示它丢失的目录,默认情况下所有Java脚本都应该在Scripts文件夹中。这可能不适用于上述用户。

#9


1  

I had created a new Angular application and written

我已经创建了一个新的角度应用程序并编写了它

bundles.Add(new ScriptBundle("~/bundles/app")
    .IncludeDirectory("~/Angular", "*.js")
    .IncludeDirectory("~/Angular/directives/shared", "*.js")
    .IncludeDirectory("~/Angular/directives/main", "*.js")
    .IncludeDirectory("~/Angular/services", "*.js"));

but I had created no services, so the services folder was not deployed on publish as it was empty. Unfortunately, you have to put a dummy file inside any empty folder in order for it to publish

但是我没有创建任何服务,所以services文件夹没有部署到publish上,因为它是空的。不幸的是,您必须在任何空文件夹中放置一个虚拟文件,以便它发布

https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/29/tip-105-did-you-know-how-to-include-empty-directory-when-package-a-web-application/

https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/29/tip - 105 -你知道-如何- -包括空-目录-时-包装- - web - application/

#10


1  

I too faced the same issue. Browsed to the file path under Script Folder.Copied the exact file name and made change in bundle.cs:

我也面临同样的问题。浏览到脚本文件夹下的文件路径。复制正确的文件名,并在bundl中进行更改。

Old Code : //Bundle.cs

旧代码:/ / Bundle.cs

public class BundleConfig

{

    public static void RegisterBundles(BundleCollection bundles)

    {

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.validate*"));

        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

    }
}

New Code :

新代码:

public class BundleConfig

{

      public static void RegisterBundles(BundleCollection bundles)

      {

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-1.10.2.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.validate.js"));

        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-2.6.2.js"));
      }
}

#11


1  

I had this issue when I opened a VS2017 project in VS2015, built the solution and then uploaded the DLLs.

当我在VS2015中打开一个VS2017项目,构建解决方案并上传dll时,我就遇到了这个问题。

Rebuilding it in VS2017 and re-uploading the DLLs fixed the issue.

在2017年VS2017年重新构建并重新上传dll解决了这个问题。

#12


0  

I got the same question! It seems to with IIS Express. I change the IIS Express' URL for Project Like:

我也有同样的问题!似乎与IIS Express有关。我为项目更改IIS Express的URL,如:

"http://localhost:3555/"

then the problem gone.

然后这个问题消失了。

#13


0  

This can also be caused by a race condition while deploying:

这也可能是由于部署时的种族状况:

If you use Visual Studio's "Publish" to deploy over a network file share, and check "Delete all existing files prior to publish." (I do this sometimes to ensure that we're not unknowingly still depending on files that have been removed from the project but are still hanging out on the server.)

如果您使用Visual Studio的“发布”来部署网络文件共享,并检查“在发布之前删除所有现有文件”。(我有时这样做是为了确保我们不会在不知不觉中仍然依赖于从项目中删除但仍然挂在服务器上的文件。)

If someone hits the site before all the required JS/CSS files are re-deployed, it will start Application_Start and RegisterBundles which will fail to properly construct the bundles and throw this exception.

如果有人在重新部署所有必需的JS/CSS文件之前访问了这个站点,那么它将启动Application_Start和registerbundle,这两个bundle将无法正确地构造包并抛出此异常。

But by the time you get this exception and go check the server, all the necessary files are right where they should be!

但是当您得到这个异常并检查服务器时,所有必要的文件都是正确的!

However, the application happily continues to serve the site, generating 404's for any bundle request, along with the unstyled/unfunctional pages that result from this, and never tries to rebuild the bundles even after the necessary JS/CSS files are now available.

但是,应用程序很高兴地继续为站点服务,为任何bundle请求生成404页面,以及由此产生的无样式/无功能页面,并且即使现在有了必要的JS/CSS文件,也不会尝试重新构建bundle。

A re-deploy using "Replace matching files with local copies" will trigger the app to restart and properly register the bundles this time.

使用“用本地副本替换匹配文件”重新部署将触发应用程序重新启动并正确地注册捆绑包。

#14


0  

My problem was that my site had no files to bundle. However, I had created the site with an MVC template, which includes jQuery scripts. The bundle.config referred to those files and their folders. Not needing the scripts, I deleted them. After editing the bundle.config, all was good.

我的问题是我的网站没有文件捆绑。但是,我用一个MVC模板创建了这个站点,其中包括jQuery脚本。的包。config引用了这些文件及其文件夹。由于不需要脚本,我删除了它们。后编辑包。配置,一切都好。

#15


0  

All was working fine, then while making unrelated changes and on next build came across the same issue. Used source control to compare to previous versions and discovered that my ../Content/Scripts folder had mysteriously been emptied!

一切都运行良好,然后在进行不相关的更改时,下一个构建遇到了相同的问题。使用源代码控制与以前的版本进行比较,发现。/Content/Scripts文件夹神秘地被清空!

Restored ../Content/Scripts/*.*from a backup and all worked well!

恢复. . /内容/脚本/ *。*从备份和所有工作良好!

ps: Using VS2012, MVC4, had recently updated some NuGet packages, so that might have played some part in the issue, but all ran well for a while after the update, so not sure.

ps:使用VS2012, MVC4,最近更新了一些NuGet包,这可能在问题中起到了一定的作用,但是在更新后的一段时间内都运行良好,所以不确定。

#16


0  

look into your BundleConfig.cs file for the lines that invokes IncludeDirectory()

看看你的BundleConfig。调用IncludeDirectory()的行的cs文件

ie:

即:

  bundles.Add(new Bundle("~/bundle_js_angularGrid").IncludeDirectory(
                       "~/Scripts/Grid", "*.js", true));

my Grid directory did not exist.

我的网格目录不存在。

#17


0  

I also had this error when I combined all my separated bundles into one bundle.

当我将所有分离的bundle合并到一个bundle时,我也有这个错误。

bundles.Add(new ScriptBundle("~/bundles/one").Include(
            "~/Scripts/one.js"));
bundles.Add(new ScriptBundle("~/bundles/two").Include(
            "~/Scripts/two.js"));

Changed to

更改为

bundles.Add(new ScriptBundle("~/bundles/js").Include(
            "~/Scripts/one.js",
            "~/Scripts/two.js"));

I had to refresh application pool on my shared hosting's control panel to fix this issue.

我必须刷新共享主机控制面板上的应用程序池来解决这个问题。

#18


0  

Removing this lines of code from the bundleConfig.cs class file resolved my challenge:

从bundleConfig中删除这行代码。cs类文件解决了我的挑战:

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));

#19


0  

None of these answers helped me since I created my jsx files in a weird way. My code was working in localhost mode but failed in production.

这些答案都没有帮助我,因为我以一种奇怪的方式创建了jsx文件。我的代码在localhost模式下工作,但是在生产中失败了。

The fix for me was to go into the csproj file and change the file paths from <None ... to <Content ...

我的解决方案是进入csproj文件并将文件路径从

#1


210  

I had the same problem and found out that I had some bundles that pointed to non-exisiting files using {version} and * wildcards such as

我也遇到了同样的问题,发现我有一些用{version}和*通配符(如*通配符)指向不存在的文件的包

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
    "~/Scripts/jquery-{version}.js"));

I removed all of those and the error went away.

我把这些都去掉了,误差就消失了。

#2


15  

I had this same issue and it was not a code problem. I was using the publish option (not the FTP one) and Visual Studio was not uploading some of my scripts/css to the azure server because they were not "included in my project". So, locally it worked just fine, because files were there in my hard drive. What solved this issue in my case was "Project > Show all files..." and right click the ones that were not included, include them and publish again

我也有同样的问题,这不是代码问题。我使用的是发布选项(不是FTP选项),Visual Studio没有将我的一些脚本/css上传到azure服务器,因为它们没有“包含在我的项目中”。所以,在本地它运行得很好,因为文件在我的硬盘里。在我的案例中,解决这个问题的是“项目>显示所有文件……”,然后右键单击未包含的文件,包括它们并再次发布

#3


7  

Here's a quick class I wrote to make this easier.

这是我写的一个快速的类,让它更简单。

using System.Web.Hosting;
using System.Web.Optimization;

// a more fault-tolerant bundle that doesn't blow up if the file isn't there
public class BundleRelaxed : Bundle
{
    public BundleRelaxed(string virtualPath)
        : base(virtualPath)
    {
    }

    public new BundleRelaxed IncludeDirectory(string directoryVirtualPath, string searchPattern, bool searchSubdirectories)
    {
        var truePath = HostingEnvironment.MapPath(directoryVirtualPath);
        if (truePath == null) return this;

        var dir = new System.IO.DirectoryInfo(truePath);
        if (!dir.Exists || dir.GetFiles(searchPattern).Length < 1) return this;

        base.IncludeDirectory(directoryVirtualPath, searchPattern);
        return this;
    }

    public new BundleRelaxed IncludeDirectory(string directoryVirtualPath, string searchPattern)
    {
        return IncludeDirectory(directoryVirtualPath, searchPattern, false);
    }
}

To use it, just replace ScriptBundle with BundleRelaxed in your code, as in:

要使用它,只需在代码中使用BundleRelaxed替换ScriptBundle,如下所示:

        bundles.Add(new BundleRelaxed("~/bundles/admin")
            .IncludeDirectory("~/Content/Admin", "*.js")
            .IncludeDirectory("~/Content/Admin/controllers", "*.js")
            .IncludeDirectory("~/Content/Admin/directives", "*.js")
            .IncludeDirectory("~/Content/Admin/services", "*.js")
            );

#4


3  

I ran into the same issue today it is actually I found that some of files under ~/Scripts is not published. The issue is resolved after I published the missing files

我今天遇到了同样的问题,实际上我发现~/Scripts下面的一些文件没有发布。这个问题在我发布丢失的文件之后得到了解决

#5


2  

I also got this error by having non-existant directories in my bundles.config file. Changing this:

通过在包中包含不存在的目录,我也得到了这个错误。配置文件。改变:

<?xml version="1.0"?>
<bundleConfig ignoreIfDebug="true" ignoreIfLocal="true">
    <cssBundles>
        <add bundlePath="~/css/shared">
            <directories>
                <add directoryPath="~/content/" searchPattern="*.css"></add>
            </directories>
        </add>
    </cssBundles>
    <jsBundles>
        <add bundlePath="~/js/shared">
            <directories>
                <add directoryPath="~/scripts/" searchPattern="*.js"></add>
            </directories>
            <!--
            <files>
                <add filePath="~/scripts/jscript1.js"></add>
                <add filePath="~/scripts/jscript2.js"></add>
            </files>
            -->
        </add>
    </jsBundles>
</bundleConfig>

To this:

:

<?xml version="1.0"?>
<bundleConfig ignoreIfDebug="true" ignoreIfLocal="true">
    <cssBundles>
    </cssBundles>
    <jsBundles>
    </jsBundles>
</bundleConfig>

Solve the problem for me.

帮我解决这个问题。

#6


2  

Like @JerSchneid, my problem was empty directories, but my deployment process was different from the OP. I was doing a git-based deploy on Azure (which uses Kudu), and didn't realize that git doesn't include empty directories in the repo. See https://*.com/a/115992/1876622

和@JerSchneid一样,我的问题是空目录,但是我的部署过程与opi不同,我在Azure上做基于gitanjt的部署(使用Kudu),并没有意识到git不包括repo中的空目录。参见https://*.com/a/115992/1876622

So my local folder structure was:

所以我的本地文件夹结构是:

[Project Root]/Content/jquery-plugins // had files

[项目根]/内容/jquery-plugins /有文件

[Project Root]/Scripts/jquery-plugins // had files

[项目根]/脚本/jquery-plugins /有文件

[Project Root]/Scripts/misc-plugins // empty folder

[项目根]/脚本/错误插件/空文件夹

Whereas any clone / pull of my repository on the remote server was not getting said empty directory:

鉴于远程服务器上对我的存储库的任何克隆/拉取都没有得到这个空目录:

[Project Root]/Content/jquery-plugins // had files

[项目根]/内容/jquery-plugins /有文件

[Project Root]/Scripts/jquery-plugins // had files

[项目根]/脚本/jquery-plugins /有文件

The best approach to fixing this is to create a .keep file in the empty directory. See this SO solution: https://*.com/a/21422128/1876622

解决此问题的最佳方法是在空目录中创建.keep文件。请参阅SO解决方案:https://*.com/a/214228/1876622

#7


2  

I had the same issue. the problem in my case was that the script's folder with all the bootstrap/jqueries scripts was not in the wwwroot folder. once I added the script's folder to wwwroot the error went away.

我也有同样的问题。在我的例子中,问题是带有所有引导/jqueries脚本的脚本文件夹不在wwwroot文件夹中。一旦我将脚本的文件夹添加到wwwroot中,错误就消失了。

#8


1  

This may be an old issue.I have similar error and in my case it was Scripts folder hiding in my Models Folder. Stack trace clearly says its missing Directory and by default all Java Scripts should be in Scripts Folder. This may not be applicable to above users.

这可能是个老问题。我也有类似的错误,在我的例子中它是隐藏在我的模型文件夹中的脚本文件夹。堆栈跟踪明确表示它丢失的目录,默认情况下所有Java脚本都应该在Scripts文件夹中。这可能不适用于上述用户。

#9


1  

I had created a new Angular application and written

我已经创建了一个新的角度应用程序并编写了它

bundles.Add(new ScriptBundle("~/bundles/app")
    .IncludeDirectory("~/Angular", "*.js")
    .IncludeDirectory("~/Angular/directives/shared", "*.js")
    .IncludeDirectory("~/Angular/directives/main", "*.js")
    .IncludeDirectory("~/Angular/services", "*.js"));

but I had created no services, so the services folder was not deployed on publish as it was empty. Unfortunately, you have to put a dummy file inside any empty folder in order for it to publish

但是我没有创建任何服务,所以services文件夹没有部署到publish上,因为它是空的。不幸的是,您必须在任何空文件夹中放置一个虚拟文件,以便它发布

https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/29/tip-105-did-you-know-how-to-include-empty-directory-when-package-a-web-application/

https://blogs.msdn.microsoft.com/webdevelopertips/2010/04/29/tip - 105 -你知道-如何- -包括空-目录-时-包装- - web - application/

#10


1  

I too faced the same issue. Browsed to the file path under Script Folder.Copied the exact file name and made change in bundle.cs:

我也面临同样的问题。浏览到脚本文件夹下的文件路径。复制正确的文件名,并在bundl中进行更改。

Old Code : //Bundle.cs

旧代码:/ / Bundle.cs

public class BundleConfig

{

    public static void RegisterBundles(BundleCollection bundles)

    {

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.validate*"));

        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

    }
}

New Code :

新代码:

public class BundleConfig

{

      public static void RegisterBundles(BundleCollection bundles)

      {

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-1.10.2.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.validate.js"));

        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-2.6.2.js"));
      }
}

#11


1  

I had this issue when I opened a VS2017 project in VS2015, built the solution and then uploaded the DLLs.

当我在VS2015中打开一个VS2017项目,构建解决方案并上传dll时,我就遇到了这个问题。

Rebuilding it in VS2017 and re-uploading the DLLs fixed the issue.

在2017年VS2017年重新构建并重新上传dll解决了这个问题。

#12


0  

I got the same question! It seems to with IIS Express. I change the IIS Express' URL for Project Like:

我也有同样的问题!似乎与IIS Express有关。我为项目更改IIS Express的URL,如:

"http://localhost:3555/"

then the problem gone.

然后这个问题消失了。

#13


0  

This can also be caused by a race condition while deploying:

这也可能是由于部署时的种族状况:

If you use Visual Studio's "Publish" to deploy over a network file share, and check "Delete all existing files prior to publish." (I do this sometimes to ensure that we're not unknowingly still depending on files that have been removed from the project but are still hanging out on the server.)

如果您使用Visual Studio的“发布”来部署网络文件共享,并检查“在发布之前删除所有现有文件”。(我有时这样做是为了确保我们不会在不知不觉中仍然依赖于从项目中删除但仍然挂在服务器上的文件。)

If someone hits the site before all the required JS/CSS files are re-deployed, it will start Application_Start and RegisterBundles which will fail to properly construct the bundles and throw this exception.

如果有人在重新部署所有必需的JS/CSS文件之前访问了这个站点,那么它将启动Application_Start和registerbundle,这两个bundle将无法正确地构造包并抛出此异常。

But by the time you get this exception and go check the server, all the necessary files are right where they should be!

但是当您得到这个异常并检查服务器时,所有必要的文件都是正确的!

However, the application happily continues to serve the site, generating 404's for any bundle request, along with the unstyled/unfunctional pages that result from this, and never tries to rebuild the bundles even after the necessary JS/CSS files are now available.

但是,应用程序很高兴地继续为站点服务,为任何bundle请求生成404页面,以及由此产生的无样式/无功能页面,并且即使现在有了必要的JS/CSS文件,也不会尝试重新构建bundle。

A re-deploy using "Replace matching files with local copies" will trigger the app to restart and properly register the bundles this time.

使用“用本地副本替换匹配文件”重新部署将触发应用程序重新启动并正确地注册捆绑包。

#14


0  

My problem was that my site had no files to bundle. However, I had created the site with an MVC template, which includes jQuery scripts. The bundle.config referred to those files and their folders. Not needing the scripts, I deleted them. After editing the bundle.config, all was good.

我的问题是我的网站没有文件捆绑。但是,我用一个MVC模板创建了这个站点,其中包括jQuery脚本。的包。config引用了这些文件及其文件夹。由于不需要脚本,我删除了它们。后编辑包。配置,一切都好。

#15


0  

All was working fine, then while making unrelated changes and on next build came across the same issue. Used source control to compare to previous versions and discovered that my ../Content/Scripts folder had mysteriously been emptied!

一切都运行良好,然后在进行不相关的更改时,下一个构建遇到了相同的问题。使用源代码控制与以前的版本进行比较,发现。/Content/Scripts文件夹神秘地被清空!

Restored ../Content/Scripts/*.*from a backup and all worked well!

恢复. . /内容/脚本/ *。*从备份和所有工作良好!

ps: Using VS2012, MVC4, had recently updated some NuGet packages, so that might have played some part in the issue, but all ran well for a while after the update, so not sure.

ps:使用VS2012, MVC4,最近更新了一些NuGet包,这可能在问题中起到了一定的作用,但是在更新后的一段时间内都运行良好,所以不确定。

#16


0  

look into your BundleConfig.cs file for the lines that invokes IncludeDirectory()

看看你的BundleConfig。调用IncludeDirectory()的行的cs文件

ie:

即:

  bundles.Add(new Bundle("~/bundle_js_angularGrid").IncludeDirectory(
                       "~/Scripts/Grid", "*.js", true));

my Grid directory did not exist.

我的网格目录不存在。

#17


0  

I also had this error when I combined all my separated bundles into one bundle.

当我将所有分离的bundle合并到一个bundle时,我也有这个错误。

bundles.Add(new ScriptBundle("~/bundles/one").Include(
            "~/Scripts/one.js"));
bundles.Add(new ScriptBundle("~/bundles/two").Include(
            "~/Scripts/two.js"));

Changed to

更改为

bundles.Add(new ScriptBundle("~/bundles/js").Include(
            "~/Scripts/one.js",
            "~/Scripts/two.js"));

I had to refresh application pool on my shared hosting's control panel to fix this issue.

我必须刷新共享主机控制面板上的应用程序池来解决这个问题。

#18


0  

Removing this lines of code from the bundleConfig.cs class file resolved my challenge:

从bundleConfig中删除这行代码。cs类文件解决了我的挑战:

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));

#19


0  

None of these answers helped me since I created my jsx files in a weird way. My code was working in localhost mode but failed in production.

这些答案都没有帮助我,因为我以一种奇怪的方式创建了jsx文件。我的代码在localhost模式下工作,但是在生产中失败了。

The fix for me was to go into the csproj file and change the file paths from <None ... to <Content ...

我的解决方案是进入csproj文件并将文件路径从