我刚刚在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
这是什么意思?
发布于 2012-10-05 00:25:25
我也遇到了同样的问题,并发现我有一些包使用{version}和*通配符指向不存在的文件,例如
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
我删除了所有这些,错误也就消失了。
发布于 2014-01-27 13:25:09
我也遇到了同样的问题,这不是代码问题。我使用的是发布选项(而不是FTP选项),Visual Studio没有将我的一些脚本/css上传到azure服务器,因为它们没有“包含在我的项目中”。所以,在本地它工作得很好,因为文件就在我的硬盘里。在我的案例中,解决这个问题的方法是"Project > Show all files...“然后右键单击未包含的内容,将其包含并再次发布
发布于 2013-06-18 05:11:04
下面是我编写的一个快速类,目的是让这一切变得更简单。
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);
}
}
要使用它,只需在代码中将ScriptBundle替换为BundleRelaxed,如下所示:
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")
);
https://stackoverflow.com/questions/11317384
复制相似问题