简体   繁体   English

部署到Azure ASP MVC 4时捆绑不起作用

[英]Bundling not working when deployed to azure asp mvc 4

I have css files and js files, locally link are rendered in the head as expected but on azure the links are not rendered at all, why? 我有css文件和js文件,本地链接按预期方式显示在头部,但是天蓝色时根本不显示链接,为什么?

I have looked through various threads and most seem to point towards there being an issue with naming the bundle name the same as the file path, both are different. 我浏览了各种线程,大多数似乎都指向将包名称命名为与文件路径相同的问题,两者都不同。 Others have said that <compilation debug="true" targetFramework="4.5" /> should be <compilation debug="false" targetFramework="4.5" /> and others have said to try BundleTable.EnableOptimizations = true; 其他人说<compilation debug="true" targetFramework="4.5" />应该是<compilation debug="false" targetFramework="4.5" /> ,其他人则说尝试BundleTable.EnableOptimizations = true; in the Bundle.config. 在Bundle.config中。 Non have worked for me, can someone please point me in the right direction 非为我工作过,有人可以指出正确的方向吗

my bundles are 我的包是

bundles.Add(new StyleBundle("~/assets/styles").Include(
                    "~/assets/plugins/bootstrap/css/bootstrap.min.css",
                    "etc...",
                    "~/assets/css/theme.css"));

        bundles.Add(new ScriptBundle("~/assets/scripts").Include(
                    "~/assets/js/filter.js",
                    "etc...",
                    "~/assets/js/ContactForm.js"));

my folder structure is 我的文件夹结构是

assets/css
assets/js

in my _Layout.cshtml they are called 在我的_Layout.cshtml中,它们被称为

@Styles.Render("~/assets/styles")
@Scripts.Render("~/assets/scripts") 

It's likely due to the assets folder already existing. 可能是由于assets文件夹已经存在。 Have you tried just using ~/styles and ~/scripts ? 您是否尝试过仅使用~/styles~/scripts

The assumption you've made is that because the assets/styles folder doesn't exist a virtual path will be created. 您所做的假设是,因为assets/styles文件夹不存在,所以将创建虚拟路径。 The issue is more likely to do with Azure discovering the Directory assets and treating everything within it as actual resources, skipping past the point of creating a virtual path. 问题很可能与Azure发现目录assets并将其中的所有内容都视为实际资源有关,从而跳过了创建虚拟路径的要点。 If I were you, I wouldn't bother with trying to make it work, at best you'll have what you wanted but really, at worst, you'll have wasted hours on a matter that makes no business sense and adds no real value to the UX... 如果我是你,我不会为使它工作而烦恼,充其量只有你想要的东西,但实际上,最糟糕的是,你会浪费时间在没有商业意义,没有实质意义的事情上UX的价值...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 部署Windows Server 2012 RC时MVC 4捆绑不起作用 - MVC 4 bundling not working when deployed Windows Server 2012 RC 部署时,asp mvc 2结构图不起作用 - asp mvc 2 structure map not working when deployed Bootstrap不能与ASP.net MVC Bundling一起使用 - Bootstrap not working with ASP.net MVC Bundling 在Microsoft Windows Azure中部署时使用smtp发送的邮件不起作用c#asp.net mvc5 - Sent mail using smtp not working when deployed in microsoft windows azure c# asp.net mvc5 捆绑ASP MVC 5包含非捆绑文件 - Bundling ASP MVC 5 Include Non Bundling File 当我打开发布模式时,捆绑在 MVC5 中不起作用 - Bundling not working in MVC5 when I turn on release mode 用于检索所有用户的ASP.NET MVC Active Directory代码在部署到IIS 7时停止工作 - ASP.NET MVC Active Directory code to retrieve all users stops working when deployed to IIS 7 Web api在本地工作,但在部署到Azure时则不能 - Web api working locally but not when deployed to Azure 部署到天蓝色的Google身份验证不起作用 - Google authentication not working when deployed to azure 部署到Azure网站时WebApi不工作 - WebApi Not Working When Deployed to Azure Website
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM