.cshtml files not working IIS [closed]

2020-02-01 06:23发布

I have Windows Server 2012, I configure IIS 8 to work with .cshtml files.

  • I already installed ASP.NET
  • I've added .cshtml to MIME types
  • I have the DLL in the bin folder.

but when I open a page the code just appears like simple text.

What have I done wrong? How can I fix this so that the .cshtml is rendered as a web page?

1条回答
干净又极端
2楼-- · 2020-02-01 07:07

You probably need to install ASP.Net Webpages. You can get it along with MVC4 using the standalone installer here: http://www.asp.net/mvc/mvc4

Also, did you enable ASP.Net webpages in web.config?

 <add key="webpages:Enabled" value="true" />

webPages:enabled with value false prevents .cshtml or .vbhtml files in the Views folder from being directly accessible from a web browser.

查看更多
登录 后发表回答