.cshtml文件显示为纯HTML [英] .cshtml files displaying as plain html

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

问题描述

我有一个问题,建立托管的Windows Server 2012的网站上的网站只是默认网站设立一个新的ASP.NET网站(剃刀V2)的网站,当你得到。然后,我只是用VS2012发布网站选项刊登出来。我还添加了MIME类型.cshtml扩展。服务器正在运行IIS V8和.NET V4。问题是,当我浏览网页,这是它如何显示:

I am having a problem setting up a website hosted on Windows Server 2012. The website is just the default website you get when setting up a new "ASP.NET Web Site (Razor v2)" site. Then I simply published it using the "Publish Web Site" option in VS2012. I have also added the .cshtml extension in the MIME types. The server is running IIS v8 and .NET v4. The problem is when I visit the website this is how it displays:

http://i806.photobucket.com/albums/ yy341 / SamuelCB /剃刀%20Error / Untitled.png

有什么我失踪?

推荐答案

检查项目:


  • 很少做,如果IIS ASP.Net是否安装正确MIME类型实际上很重要

  • rarely do MIME Types actually matter if IIS and ASP.Net are installed properly


  • 不误间preT此声明,我不是说MIME类型并不重要,只是如果/当正确配置了这一切,IIS / ASP.Net是出的盒子,而不使用MIME类型搞混。

  • don't mis-interpret this statement, I'm not saying MIME types don't matter, just that if/when configured properly all of this, IIS/ASP.Net is "out of the box" without mucking with MIME types.

与加入.cshtml问题是手动就是IIS会(现在的)服务,但在ASP.Net引擎不处理它(例如集成模式)(不一定是有了)。这就是为什么你看到的未解析(RAW)文件... code和版本的所有......这一切都IIS(不ASP.net引擎配置为处理它)。

The issue with adding ".cshtml" manually is that IIS will (now) serve it, but the ASP.Net engine isn't (necessarily "there" for) handling it (e.g. integrated mode). That's why you're seeing the "unparsed" (raw) version of the file...code and all...it's all IIS (no ASP.net engine is configured to handle it).

如果您有自己的盒子,跑 Web平台安装 - 它应该给你什么的安装与什么不是洞察力。注意ASP.Net位和版本。您的可能的需要 (重新)注册ASP.Net

if you run your own box, run Web Platform Installer - and it should give you insight on what's installed vs. what's not. Pay attention to ASP.Net bits and versions. You may need to (re)register ASP.Net

如果你正在主持,只是因为你的主机有 .Net框架4.x版安装的的意思是,他们拥有所有的点点滴滴 ASP.Net的安装好。的问问你的主机指导的而不是做一个猜谜游戏。我经常要负荷的东西,我的开发机器有默认(当然它在我的机器),因为我结束了非功能性的东西时,部署到我的主机。你甚至没有得到一个ASP.Net引擎错误,所以这是一个明确的信号ASP.Net需要一些工作。

if you're hosted, just because your host has .Net Framework 4.x installed, doesn't mean they have all the bits and pieces of ASP.Net installed as well. Ask your host for guidance instead of doing a guessing game. I often have to "load" things that my dev machine has "by default" (of course its my machine) because I end up with non-functioning stuff when deployed to my host. You're not even getting an ASP.Net engine error, so that's a sure sign ASP.Net needs some work.


  • 的NuGet 非常适合这项任务。这可能需要一些项目进行的bin部署(又名您必须将它们添加到您的部署/上传到 / bin中目录主机):

    • 微软ASP.NET剃须刀

    • 微软ASP.NET网页

    • Microsoft.Web.Infrastructure

    • Nuget is excellent for this task. Some items that might be necessary to be "bin deployed" (aka. you have to add them to your deployment/upload to /bin directory on your host):
      • Microsoft ASP.NET Razor
      • Microsoft ASP.NET Web Pages
      • Microsoft.Web.Infrastructure

      无关:这听起来更像是它应该去 ServerFault ,而不是在这里所以......我不介意......但社区可以有不同的想法......你甚至可能会得到更好的答案......

      Unrelated: This sounds more like it should go to ServerFault rather than here on SO...I don't mind...but the community may think differently...and you might even get better answers....

      Hth以上...

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

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