I am trying to get my server to run .cshtml files. Using WebMatrix 3, I can view the pages by right-clicking and selecting “view in browser”, but this is viewing through the local port. If I try to access pages from the Internet, I get 500 errors.
Here is what I did:
- I made sure that MVC 3 was installed (but I continue to read that MVC is not needed for .cshtml ... I made sure anyway.
- I made the whole "go back to parent" / "go back to inherited" thing that is found on many blogs.
- I was getting 404 error for a while, so I added the "text / html" MIME type to the .cshtml extension. This solved this problem, but only led to my 500 error.
I suspect this is due to my web.config file, because if I delete the file, the page will show, but it reads as text. For example (on the most basic page that I could think of):
@{ var currentTime = dateTime.Now; } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Testing</title> <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" /> </head> <body> The current time is @currentTime . </body> </html>
The page will look like this:
@{ var currentTime = dateTime.Now;} Current time @currentTime .
However, I do not know what should or should not be in the web.config file. For a month now I have been deceiving my brain ...
Here is what is in the web.config file:
<configuration> <system.data> <DbProviderFactories> <remove invariant="System.Data.SqlServerCe.4.0" /> <add invariant="System.Data.SqlServerCe.4.0" name="Microsoft® SQL Server® Compact 4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /> </DbProviderFactories> </system.data> <appSettings> <add key="webPages:Version" value="2.0"/> <add key="webpages:Enabled" value="true" /> </appSettings> <system.webServer> <httpErrors errorMode="Detailed" /> </system.webServer> </configuration>
Thank you very much in advance.
source share