Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up visual studio to create CSHTML files in (Umbraco) Project

Tags:

razor

umbraco

So, i'm developing my razor macroscripts in Visual studio for my Umbraco project. Everything is working fine, but there are two things really annoying.

  • If I want to make a new CSHTML file the best solution for this is to duplicate an existing file.
  • I dont have full razor IntelliSense like e.g. Html.Raw

Is there a way to configure my project to use this features? Didn't find a .cshtml template yet.

like image 321
Gigi2m02 Avatar asked May 08 '12 15:05

Gigi2m02


People also ask

What is Cshtml in Visual Studio?

cshtml extension is a C# HTML file that is used at server side by Razor Markup engine to render the webpage files to user's browser. This server side coding is similar to the standard ASP.NET page enabling dynamic web content creation on the fly as the webpage is written to the browser.

How do I open an Umbraco project in Visual Studio?

Open Visual Studio Code, go to Extensions, search for IIS Express for VSCode and install it. Open the folder containing the extracted Zip folder of Umbraco CMS. Now you can run the Umbraco CMS in a browser by hitting CTRL+F5 then choosing which browser in the prompt window.


2 Answers

You need to have the MVC Framework installed, then when you open the project as a website, you should be able to create and edit cshtml files with syntax highlighting. See my answer to the following post for more details:

Setting up local development environment for Umbraco

like image 151
Douglas Ludlow Avatar answered Sep 21 '22 20:09

Douglas Ludlow


If your project is a web site/application then the mvc templates aren't available (they only show up in MVC projects). You can just create a text file and name it with the .cshtml extension though (you could set up your own template for this in VS if you wanted to).

To get intellisense in your Razor files, see Doug Robar's blog post on the subject

like image 42
Tim Avatar answered Sep 19 '22 20:09

Tim