简体   繁体   English

ASP.NET MVC 5解决方案在VS2013中有效,但在VS2015中不适用

[英]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 . 我有在Visual Studio 2013中开发的ASP.NET MVC 5应用程序。 Everything works well when I run the solution in the IDE. 当我在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. 现在,当我在Visual Studio 2015的同一台计算机上运行完全相同的解决方案时,它不会加载CSS和javascript文件。 Debugging in the browser revealed that with VS 2013 the GET requests for the static resources are successful and getting a 200 OK. 在浏览器中进行的调试显示,使用VS 2013,对静态资源的GET请求成功完成,并获得200 OK。 With VS2015 I get a 500 Internal Server Error. 使用VS2015时,我收到500内部服务器错误。

I am using IIS Express when running the solution in Visual Studio. 在Visual Studio中运行解决方案时,我正在使用IIS Express。

Example: requesting jquery.validate.js: 示例:请求jquery.validate.js:

Screenshot when using VS 2013 使用VS 2013时的屏幕截图

Screenshot when using VS 2015 使用VS 2015时的屏幕截图

Edit: 编辑:

I don't think the problem is in the code, because it works in VS2013 and on the servers. 我不认为问题出在代码中,因为它可以在VS2013和服务器上使用。 But here's some code: 但是这是一些代码:

Some scripts are implementet via bundling: 一些脚本通过捆绑实现:

BundleConfig: 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: 与CSS相同:

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

Again, its all working nicely in VS2013 and on deplyoment servers, but NOT in VS2015. 同样,它在VS2013和部署服务器上都可以正常运行,但在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'". 在chrome调试器中对网络标签信息的进一步检查显示了一条错误消息“无法添加具有唯一键属性'fileExtension'的'mimeMap'类型的重复收集条目”。

I found an entry in my web.config file which was causing this error: 我在我的web.config文件中找到一个条目,该条目导致此错误:

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

This page showed me the solution. 此页面向我展示了解决方案。

I changed my web.config to: 我将web.config更改为:

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

which did the trick. 绝招。 My website is now running fine in VS2015. 我的网站现在在VS2015中运行良好。

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

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