Visual Studio 2017 cshtml 文件错误 [英] Visual Studio 2017 cshtml file errors

查看:56
本文介绍了Visual Studio 2017 cshtml 文件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在新的 VS2017 中打开了我现有的 VS2015 解决方案.希望它能正常工作,但是,我在诸如 @model、@ViewBag、@ActionLink、@Url、@Partial、@Scripts、@Styles 以及 where 子句中的 lambda 表达式之类的词下看到了很多红线在页面模型上.

不确定有什么遗漏或错误.解决方案已构建,但在 cshtml 文件中显示错误.

任何帮助或指导都会有所帮助.

提前致谢.肯

解决方案

我遇到了这个问题并且

MVC 4.0.0.0 -> 5.2.3.0

I opened my existing VS2015 solution in the new VS2017. Was hoping it would just work, however, I am seeing a lot of red lines under words like - @model, @ViewBag, @ActionLink, @Url, @Partial, @Scripts, @Styles, and under lambda expressions in the where clause on the model for the page.

Not sure what is missing or wrong. The solution builds, but shows errors in the cshtml files.

Anyone help or direction would be helpful.

Thanks in advance. Ken

解决方案

I had this issue and https://stackoverflow.com/a/19696998/4484478 fixed it for me. My solution was created with VS2012. I started using VS2013 and VS2015 to work on this solution after RTM came out and the issue OP described occurred after I started using VS2017.

From the answer post:

Create a new project targeting same .NET framework and copy its Views/web.config file over top the one in your current project.

Note that the web.config here is the one inside the Views folder and not the main one. This is probably the simplest way to fix it. But if you have some other customization in this file you can try editing manually the version numbers for Razor and MVC. Mine changed from 2.0.0.0 -> 3.0.0.0 for Razor

And 4.0.0.0 -> 5.2.3.0 for MVC

这篇关于Visual Studio 2017 cshtml 文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆