开发者

MVC 3 with Razor best practices

开发者 https://www.devze.com 2023-02-21 02:09 出处:网络
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 the

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 Ra开发者_JS百科zor.

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


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


Razor syntax is not all that you are looking for, you want the best patterns and practices with using MVC 3 as well. It is a shame there are Zero books out on MVC3, only web references with vary from small to large degree. At this point you must use stackoverflow and constantly use google and set a date range to search past month or so. Also, setup a google "alert" on mvc 3 razor etc..

I find that pluralsight examples, nerddinner, Silk (MileageStats), MvcMusicStore, ProDinner, and several others to be "useful" yet not one is (or can be) the best practices in every area. Everyone tries the "happy path" but many of the example veer from this. Many examples are doing various IOC containers. Some use Unity others Structuremap, others Ninject. Depending on skill level and existing knowledge, it can be overwhelming.

Personally I'm on a new project with vs 2010 / mvc3 with Oracle 9... Thus MOST of the examples are not terribly helpful as the database integration with EntityFramework use datacontext / IQueryable is great and all, but with Oracle EF in beta, and sprocs not even working with Oracle 9 with EF (per trying , and email responses from Oracle trainers etc..) I end up having to go old school and retrofit ADO.NET and convert to List ... and use IEnumerable. Thus many of the things stubbed out for easy use in the models/controllers/views in the demo projects are half in vain for me with my environment with Oracle.


Well... I use MVC 2 and work and MVC 3 at home and I really haven't found too many differences in terms of best practices for the Razor syntax. I generally just read ScottGu's or Phil Haack's blogs if I want to read about ways to use the features of Razor. Not sure if that helps you any but I am drawing a blank.


Please check below link for example with good presentation. http://dotnetautor.de/blog/content/binary/Windows-Live-Writer/32ee537b2c00_E16A/MVC3.pdf

0

精彩评论

暂无评论...
验证码 换一张
取 消