C# 捆绑-应用程序路径错误
我使用nuget包进行css和js绑定和缩小 我在这个路径中创建了一个bundleC# 捆绑-应用程序路径错误,c#,javascript,asp.net,css,bundling-and-minification,C#,Javascript,Asp.net,Css,Bundling And Minification,我使用nuget包进行css和js绑定和缩小 我在这个路径中创建了一个bundle~/bundles/shared.css BundleTable.Bundles.Add( new StyleBundle("~/bundles/shared.css") .Include( "~/Style/DevexpressAdapter.css", "~/Style/Site.css", "~/js/jquery-ui-1.10.4.cu
~/bundles/shared.css
BundleTable.Bundles.Add(
new StyleBundle("~/bundles/shared.css")
.Include(
"~/Style/DevexpressAdapter.css",
"~/Style/Site.css",
"~/js/jquery-ui-1.10.4.custom/css/flick/jquery-ui-1.10.4.custom.min.css"));
当我在localhost上运行项目时(使用VisualStudio中的CTRL+F5),它运行得很好。如果我点击http://localhost/bundles/shared.css
然后,我为添加到捆绑包中的所有文件获取缩小的组合css
但在发布位置,它不起作用
网站以http://192.168.1.8/MyApp/
地址
当我查看html时,缩小包的url是src=“/MyApp/bundles/shared.css”
。但是如果我点击http://192.168.1.8/MyApp/bundles/shared.css
我收到一个“未找到资源”错误。如果我也点击http://192.168.1.8/MyApp/MyApp/bundles/shared.css
我也遇到了同样的错误
发生了什么,我该如何解决这个问题?我不能在生产服务器上碰任何东西。我只能将文件复制到我有权访问的共享文件夹中
似乎捆绑包的url解析不正确。
我希望呈现包的url不会包含
/MyApp/
部分而不是提供虚拟路径,请尝试使用以下方法使用物理路径
Server.MapPath()。捆绑包的路径必须始终是应用程序相对url,而不是物理路径,否则会引发异常。此外,捆绑包不是驻留在磁盘上某个位置的实际文件。它是在浏览器访问捆绑包的url时动态创建并返回到响应的内容。