asp.net运行时错误:没有为扩展名".cshtml"注册的提供程序。

解决方法:

一.

 在machine.config或web.config中的<compilation><buildProviders>节注册一个。请确保所注册的提供程序具有包含值“web“或”all“的BuildProviderAppliesToAttribute特性
 在machine.config或web.config中修改原来的<compilation>

<compilation debug="true" targetFramework="4.5">
<buildProviders>
<add extension=".cshtml" type="System.Web.Compilation.PageBuildProvider"/>
</buildProviders>
</compilation>