Sometimes Code
Sometimes Code

Reputation: 601

How to add razor view file (.cshtml) in View

I am novice in MVC. I am just stuck in adding a .cshtml page in View.

I have created a Asp.Net MVC Web Application. When i right click on View folder to add View, it adds a .aspx file as a view rather than a .cshtml file.

should i have to install anything to add a .cshtml file?

Upvotes: 1

Views: 12540

Answers (5)

Before create .cshtml you must to install ASP.NET. At this page you can by step create .cshtml file: https://visualstudiomagazine.com/articles/2022/05/16/vs2022-web-forms-tip.aspx

Upvotes: 0

sudathG
sudathG

Reputation: 77

This answer for visual studio 2022

  1. Right click folder, Go to "Add" and click "New Item" enter image description here

2.Search "razor" in here. and You can select "Razor View Start"

enter image description here

  1. Click that. Now you can create ".cshtml" file

enter image description here

Upvotes: 0

Venkatesh
Venkatesh

Reputation: 1224

Razor view engine is only available from MVC version 3, if you are not using this version you cannot use razor view engine. get if from here mvc 3 update for visual studio 2010

Upvotes: 1

sanjeev
sanjeev

Reputation: 1407

I think you didn't select razor view engine while creating project

enter image description here

enter image description here

Upvotes: 1

Mohamad Shiralizadeh
Mohamad Shiralizadeh

Reputation: 8765

you can add a view by right clicking on View folder click Add and select View Add View in vs 2013

enter image description here

or right clicking on View folder click Add and select New Item and choose mvc template

Upvotes: 4

Related Questions