简体   繁体   中英

ASP.NET MVC 5 solution working in VS2013 but not in VS2015

I have an ASP.NET MVC 5 application developed in Visual Studio 2013 . Everything works well when I run the solution in the IDE. Everything works also fine on test and production servers.

Now when I run the exact same solution on the same machine in Visual Studio 2015 it doesn't load css and javascript files. Debugging in the browser revealed that with VS 2013 the GET requests for the static resources are successful and getting a 200 OK. With VS2015 I get a 500 Internal Server Error.

I am using IIS Express when running the solution in Visual Studio.

Example: requesting jquery.validate.js:

Screenshot when using VS 2013

Screenshot when using VS 2015

Edit:

I don't think the problem is in the code, because it works in VS2013 and on the servers. But here's some code:

Some scripts are implementet via bundling:

BundleConfig:

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.validate*"));

In the Layout view:

@Scripts.Render("~/bundles/jqueryval")

Other scripts are implemented directly on the view:

<script src="~/Scripts/vendor/modernizr-2.8.3-respond-1.4.2.min.js"></script>

Same with CSS:

<link href="~/Content/style.css" rel="stylesheet">

Again, its all working nicely in VS2013 and on deplyoment servers, but NOT in VS2015.

Anyone got an idea?

I finally found a solution to my problem.

Further examination of the network tab information in the chrome debugger revealed an error message "cannot add duplicate collection entry of type 'mimeMap' with unique key attribute 'fileExtension'".

I found an entry in my web.config file which was causing this error:

<staticContent>
  <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>

This page showed me the solution.

I changed my web.config to:

<staticContent>
  <remove fileExtension=".woff2" />
  <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>

which did the trick. My website is now running fine in VS2015.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM