asp.net-mvc – 运行时错误没有为扩展名’.cshtml’注册的构建提供程序

当我尝试在mvc 4中运行我的脚手架视图时,我收到以下错误:

Server Error in ‘/’ Application.
There is no build provider registered for the extension ‘.cshtml’. You can register one in the section in
machine.config or web.config. Make sure is has a
BuildProviderAppliesToAttribute attribute which includes the value
‘Web’ or ‘All’.

我发现唯一的答案与智能感知有关,但我的代码在运行时符合罚款。这是一个奇怪的错误,因为我没有使用类库。只有一个控制器可以对其所有视图发送此消息,所有其他控制器/视图都可以正常工作。

解决方法

这解决了我的问题。

在Web.config中进行更改

<compilation debug="true" targetFramework="4.5.1" optimizeCompilations="true" />

<compilation debug="true" targetFramework="4.5.1" optimizeCompilations="false" />

ADDED:几分钟后我将web.config恢复为旧,问题不重复。奇怪的东西 )

相关文章

判断URL文件是不是在于在。private static bool UrlIsExist(...
由于在.net中,Request时出现有HTML或Javascript等字符串时,...
public static bool ProcessIdCard(this string idCard, out...
protected void Page_Load(object sender, EventArgs e){ Sc...