.cshtml 文件不工作 IIS [英] .cshtml files not working IIS

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

问题描述

我有 Windows Server 2012,我将 IIS 8 配置为使用 .cshtml 文件.

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

  • 我已经安装了 ASP.NET
  • 我已将 .cshtml 添加到 MIME 类型
  • 我在 bin 文件夹中有 DLL.

但是当我打开一个页面时,代码看起来就像简单的文本.

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

我做错了什么?我该如何解决这个问题,以便将 .cshtml 呈现为网页?

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

推荐答案

您可能需要安装 ASP.Net 网页.您可以在此处使用独立安装程序将它与 MVC4 一起使用:http://www.asp.net/mvc/mvc4

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

另外,您是否在 web.config 中启用了 ASP.Net 网页?

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

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

webPages:enabled 值为 false 可防止 Views 中的 .cshtml.vbhtml 文件 文件夹不能直接从网络浏览器访问.

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

这篇关于.cshtml 文件不工作 IIS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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