2

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?

Rup
  • 33,765
  • 9
  • 83
  • 112
  • 1
    Is this webforms or MVC? You've not said anything about what you're attempting to do, only what you've done that hasn't worked. – Erik Philips Jun 26 '13 at 00:29
  • @ErikPhilips This is neither, .cshtml files let you code .net like people code php. Consider getting WebMatrix of seeing one of their tutorials about it (Generally, it's not the best of ideas). OP - better asked at serverfault as you're asking about IIS and not a programming issue. – Benjamin Gruenbaum Jun 26 '13 at 00:29
  • @BenjaminGruenbaum unless you have a link you'd like to share, the only .cshtml files I've ever seen were [Razor Views in Asp.Net MVC](http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx) which are part of ASP.Net MVC. I personally haven't seen them used outside that framework. In MVC's case they are never *run* stand alone like Classic ASP. – Erik Philips Jun 26 '13 at 00:31
  • @ErikPhilips Sure! http://www.asp.net/web-pages/tutorials/introducing-aspnet-web-pages-2/getting-started (I like ASP.NET MVC a lot better too by the way :) ) – Benjamin Gruenbaum Jun 26 '13 at 00:33
  • @BenjaminGruenbaum wow that is scary. You could probably answer this question to a simple link to [Install WebMatrix](http://www.asp.net/web-pages), thats probably the problem (in other words, the stuff that makes Web Pages 2 work isn't installed). – Erik Philips Jun 26 '13 at 00:36
  • @ErikPhilips I could probably can answer this question (It's not hard to get IIS to work with .cshtml files like OP wants), however it is off topic - it discusses how to configure the server - and it does not belong here which is why I close voted it :) – Benjamin Gruenbaum Jun 26 '13 at 00:38
  • How could this be closes as "unclear"? It´s perfectly clear to me and I have the same problem. – Asle G Feb 24 '15 at 21:08

1 Answers1

6

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.

ericdc
  • 11,217
  • 4
  • 26
  • 34