Asp.net MVC5 WebRole after deployed to Azure Cloud, breaks on @Scripts.Render

回眸只為那壹抹淺笑 提交于 2019-12-10 17:35:53

问题


I have a cloud service with an Asp.Net MVC 5 Web Role and Azure SDK 2.3 targeting 4.5.1 framework; The website works perfectly in Local. But when I deploy it to Azure Cloud service, I have the classic null reference error:

Object reference not set to an instance of an object. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 9:      @Scripts.Render("~/bundles/jquery")

My BundleConfig.cs is simple:

    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                     "~/Scripts/jquery-{version}.js",
                     "~/Scripts/knockout-{version}.js",
                     "~/Scripts/jquery.signalR-{version}.js",
                     "~/Scripts/modernizr-{version}.js"
                    ));

Using Intellitrace Logs on the WebRole I can see this error:

invalid file name for file monitoring 'E:\sitesroot\0\Scripts

Entering remotely in the instance I see that the folder Scripts is exactly in that path.

Removing the @Script.Render the page load normally. The @Style.Render on the same page works.

I tried to deploy in Debug mode, and Release mode, both in Staging.

Also tried to change in Web.config the

compilation debug="true" and false

with no success. Any ideas why could happen this? Thanks


回答1:


After days of tests I discovered that the problem is the WEBGREASE package. Updating it will cause the problem even on a fresh new project. For now uninstalling it and reinstalling the previous version solved the problem.




回答2:


Try removing everything but jquery from the jquery bundle. Then create a new bundle for the jquery dependent scripts (knockout, jquery.signalR & modernizr) and render it after the jquery bundle.



来源:https://stackoverflow.com/questions/24009122/asp-net-mvc5-webrole-after-deployed-to-azure-cloud-breaks-on-scripts-render

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!