I don't know how to use the razor code in my asp.net project. I am reading this tutorial w3school , but when i write the code in my "defaul.aspx" file then it can't run. can any one please tell me that how exactly to use the razor code in ASP.NET
Asked
Active
Viewed 117 times
0
-
Did you install the razor packages from Nuget? Razor files end in something like .cshtml – Ben Pretorius Feb 11 '14 at 10:12
-
@BenPretorius NO, i have't installed that, even i don't know how to use the razor in asp.net, i am a bit new in asp.net, can you give some suggestion? – Pir Fahim Shah Feb 11 '14 at 10:14
-
1You might as well start with this:) http://www.asp.net/mvc – Ben Pretorius Feb 11 '14 at 10:16
-
@BenPretorius can we not use the razor code in ASP.NET WP model? – Pir Fahim Shah Feb 11 '14 at 10:19
-
1You should be able to use it with ASP.NET. It is just a view engine that parse your views. The reason why it is not part of WebForms is the fact that it's core role is focused towards the MVC Pattern. – Ben Pretorius Feb 11 '14 at 10:21
-
@BenPretorius got it...! – Pir Fahim Shah Feb 11 '14 at 10:23
-
I think you just got confused by reading a w3schools "tutorial". You don't use Razor with ASPX files. If your project uses ASPX then you will not be using Razor. – John Saunders Feb 15 '14 at 19:32
-
Stick with the asp.net/mvc tutorials (http://www.asp.net/mvc/tutorials/mvc-5/introduction/getting-started), I'd stay clear of the ones on w3schools. – Christian Phillips Feb 15 '14 at 19:36
1 Answers
1
When you want to work with Razor in your asp.net Project, then you should create ".cshtml" file like Page.cshtml, write down all the code of Razor there. WebMatrix is a tool through which you can also create professional website of asp.net, and where you would have to handle the Razor. for further detail please see this liknk Razor in Asp.net

Ahmad Yar
- 26
- 2