Is there an easy way into Razor, without necessarily adopting all of MVC to begin with?
-
My question is a little vague and not simple but I will try to be as concise as possible. 1. I want to create a new website from scratch. 2. I am a professional developer but have limited web experience. 3. I have extensive C# experience and my small amount of web experience has been on ASP.NET WebForms. For this reason, I would like to stick with Microsoft technologies. 4. It is almost 100% likely I will be the only person working on the site. 5. Initially the site will be no more than 10-20 pages and can probably be static HTML/CSS. 6. Even if the site becomes successful, still it is unlikely to get any tougher than maybe being able to query a back-end database, maybe have a login facility, maybe host a blog, maybe a shopping cart. But even if all of this does one day happen, the visitor numbers are likely to be tens-per-day. I would like to move away from Web Forms because it seems to be too complex for my needs and because of this I find I never update the site. I was thinking of recreating the site initially as static HTML/CSS but I like the idea of being able to add small chunks of Razor code here and there, to keep my options open if I need to add something I can't do in HTML. So I was wondering if I can do this. Can I use Visual Studio to create a simple HTML/CSS web site that allows me to add bits of Razor code if needed? If I can do this, presumably I could later progress onto a more formal MVC architecture if I felt it was needed? And one final part to this question: should I be looking at vanilla Razor or would I be better looking into Blazor? Any help or advice would be very gratefully received. Kind wishes ~ Patrick
Thank you to anyone taking the time to read my posts.
-
My question is a little vague and not simple but I will try to be as concise as possible. 1. I want to create a new website from scratch. 2. I am a professional developer but have limited web experience. 3. I have extensive C# experience and my small amount of web experience has been on ASP.NET WebForms. For this reason, I would like to stick with Microsoft technologies. 4. It is almost 100% likely I will be the only person working on the site. 5. Initially the site will be no more than 10-20 pages and can probably be static HTML/CSS. 6. Even if the site becomes successful, still it is unlikely to get any tougher than maybe being able to query a back-end database, maybe have a login facility, maybe host a blog, maybe a shopping cart. But even if all of this does one day happen, the visitor numbers are likely to be tens-per-day. I would like to move away from Web Forms because it seems to be too complex for my needs and because of this I find I never update the site. I was thinking of recreating the site initially as static HTML/CSS but I like the idea of being able to add small chunks of Razor code here and there, to keep my options open if I need to add something I can't do in HTML. So I was wondering if I can do this. Can I use Visual Studio to create a simple HTML/CSS web site that allows me to add bits of Razor code if needed? If I can do this, presumably I could later progress onto a more formal MVC architecture if I felt it was needed? And one final part to this question: should I be looking at vanilla Razor or would I be better looking into Blazor? Any help or advice would be very gratefully received. Kind wishes ~ Patrick
Thank you to anyone taking the time to read my posts.
Are you looking for Razor Pages[^]?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Are you looking for Razor Pages[^]?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Thanks for the reply, Richard. I have visited the page you linked in my many travels on the subject but I quickly became unclear about how Razor could in any way stand alone from MVC. Having looked again at the page, I note that there is a separate link for Razor using MVC so I guess that implies what I am looking for is also contained somewhere in that section of MSDN. I'll do more research. I was just hoping to get a few informed comments about my general approach since I don't have too much free time to spend on this and ideally don't want to waste what time I do have wandering down a blind alley. Thanks again for your reply. - Patrick
Thank you to anyone taking the time to read my posts.
-
Thanks for the reply, Richard. I have visited the page you linked in my many travels on the subject but I quickly became unclear about how Razor could in any way stand alone from MVC. Having looked again at the page, I note that there is a separate link for Razor using MVC so I guess that implies what I am looking for is also contained somewhere in that section of MSDN. I'll do more research. I was just hoping to get a few informed comments about my general approach since I don't have too much free time to spend on this and ideally don't want to waste what time I do have wandering down a blind alley. Thanks again for your reply. - Patrick
Thank you to anyone taking the time to read my posts.
Razor is a view engine, just as ASPX is a view engine. The main difference between the two is that ASPX was developed based on the web-forms page model and was adapted for use with MVC. Razor, on the other hand; was built atop the MVC page model and there has been no official adaptation to any other page modeling. There was a Codeplex project for Razor, now on GIT; and a couple years old: [GitHub - Antaris/RazorEngine: Open source templating engine based on Microsoft's Razor parsing engine](https://github.com/Antaris/RazorEngine) There is also a 2-part blog set about how it's put together [Dissecting Razor, part 1: Parts of the framework – SLaks.Blog](https://blog.slaks.net/2011/01/dissecting-razor-part-1-pieces-of.html) With your personal website, I would probably just build an empty MVC project and just fill the Views with your static HTML. Not the most efficient way to do it, however; you will have the framework present to start learning Razor and MVC. As for Blazor, it still is a little young and I don't see too much going on with it to build/promote this.
Director of Transmogrification Services Shinobi of Query Language Master of Yoda Conditional
-
Razor is a view engine, just as ASPX is a view engine. The main difference between the two is that ASPX was developed based on the web-forms page model and was adapted for use with MVC. Razor, on the other hand; was built atop the MVC page model and there has been no official adaptation to any other page modeling. There was a Codeplex project for Razor, now on GIT; and a couple years old: [GitHub - Antaris/RazorEngine: Open source templating engine based on Microsoft's Razor parsing engine](https://github.com/Antaris/RazorEngine) There is also a 2-part blog set about how it's put together [Dissecting Razor, part 1: Parts of the framework – SLaks.Blog](https://blog.slaks.net/2011/01/dissecting-razor-part-1-pieces-of.html) With your personal website, I would probably just build an empty MVC project and just fill the Views with your static HTML. Not the most efficient way to do it, however; you will have the framework present to start learning Razor and MVC. As for Blazor, it still is a little young and I don't see too much going on with it to build/promote this.
Director of Transmogrification Services Shinobi of Query Language Master of Yoda Conditional
That's very helpful! Thank you! I'll take some time to digest what you've written and I'm sure I'll be better informed to decide upon a way forward. - Patrick
Thank you to anyone taking the time to read my posts.