Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC 3 with Razor best practices

I am looking for best practices for using Razor with MVC 3. Now what I am hoping for is some type of article, not just a list of your professed best practices, but if you have any feel free to post them.

Why is this SO worthy? It seems hard to find info on how to best use Razor with MVC views. I know about the typical MVC best practices, I am looking for Razor specific ones. Those who use Razor know that its more than a token replacer. I want to know more about how you setup the site templates using Razor.

Like I said, I am looking for a good resource on the subject.

like image 288
CrazyDart Avatar asked Mar 30 '11 21:03

CrazyDart


People also ask

Can you use MVC with razor pages?

You can add support for Pages to any ASP.NET Core MVC app by simply adding a Pages folder and adding Razor Pages files to this folder. Razor Pages use the folder structure as a convention for routing requests.

Which is better razor or MVC?

MVC works well with apps that have a lot of dynamic server views, single page apps, REST APIs, and AJAX calls. Razor Pages are perfect for simple pages that are read-only or do basic data input. MVC has been all the rage recently for web applications across most programming languages.

Is Cshtml a razor?

cshtml files are razorpages or MVC views, they does not contain any C#-written client-side code. If you wan to do so, you must use JavaScript. However, a . razor file, also know as a Razor component, can have C# written in it and run on client's browser.

How do you execute a method in ASP.NET MVC for every 24 hours?

You can create an external trigger that calls into your MVC action method every 24 hours. So you are executing your code every 24 hours. There are multiple ways and services to do that, i have used different services. Or you can create your own if you do not want to use third party.


1 Answers

have you ever heard of Nerddinner.com? that website has been created with ASP.NET MVC an it is open source on codeplex.

Here is the release that has razor and MVC3 version of it;

http://nerddinner.codeplex.com/SourceControl/changeset/changes/55257

You could download the source code and play with it.

Edit :

Also have a look at below blog posts;

  • ASP.NET MVC 3: Layouts and Sections with Razor
  • ASP.NET MVC 3: Implicit and Explicit code nuggets with Razor
  • Deployment of ASP.Net MVC 3 RC 2 Application on a Shared Hosting Environment Without Begging The Hosting Company
  • ASP.NET MVC 3: Layouts with Razor
  • Razor Releated posts on Phil Haacked's Blog
like image 149
tugberk Avatar answered Oct 12 '22 08:10

tugberk