我正在尝试将我的javascript文件和css文件捆绑到My MVC项目中。添加它们时会抛出异常。
Illegal characters in path.
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: Illegal characters in path.
Source Error:
Line 9: public static void RegisterBundles(BundleCollection bundles)
Line 10: {
Line 11: bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-{version}.js",
Line 12: "~/js/bootstrap.js",
Line 13: "~/js/jquery.flexslider-min.js",
"~/js/jquery.isotope.js",
"~/js/jquery.fancybox.pack.js?v=2.1.0",
"~/rs-plugin/js/jquery.themepunch.plugins.min.js",
"~/rs-plugin/js/jquery.themepunch.revolution.min.js",
"~/js/revolution.custom.js",
"~/js/custom.js"
));
Stack Trace:
[ArgumentException: Illegal characters in path.]
System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional) +10631190
System.Security.Permissions.FileIOPermission.CheckIllegalCharacters(String[] str) +30
System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) +97
System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path) +63
System.Web.InternalSecurityPermissions.PathDiscovery(String path) +29
System.Web.HttpRequest.MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, Boolean allowCrossAppMapping) +149
System.Web.HttpServerUtility.MapPath(String path) +104
System.Web.Optimization.BundleTable.<get_MapPathMethod>b__0(String virtualPath) +67
System.Web.Optimization.ItemRegistry.Include(String[] virtualPaths) +644
System.Web.Optimization.Bundle.Include(String[] virtualPaths) +64
IntensifyTech.IntensifyTechConfig.RegisterBundles(BundleCollection bundles) in c:\Users\sxxx\SkyDrive\Trunk\IntensifyTech\IntensifyTech\App_Start\IntensifyTechConfig.cs:11
IntensifyTech.MvcApplication.Application_Start() in c:\Users\sxxxx\SkyDrive\Trunk\IntensifyTech\IntensifyTech\Global.asax.cs:24
[HttpException (0x80004005): Illegal characters in path.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9859725
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Illegal characters in path.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
答案 0 :(得分:1)
是的,这绝对是这个项目:“〜/ js / jquery.fancybox.pack.js?v = 2.1.0”。这是一个虚拟路径,而不是网址,所以'?'在这种情况下,字符是非法的。