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.
我正在寻找使用Razor和MVC 3的最佳实践。现在我希望的是某种类型的文章,而不仅仅是您自称的最佳实践列表,但如果您有任何发布它们的话。
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.
这为什么值得?似乎很难找到关于如何最好地使用Razor和MVC视图的信息。我知道典型的MVC最佳实践,我正在寻找特定的Razor。那些使用Razor的人知道它不仅仅是一个代币替代品。我想了解更多关于如何使用Razor设置网站模板的信息。
Like I said, I am looking for a good resource on the subject.
就像我说的那样,我正在寻找关于这个主题的好资源。
4 个解决方案
#1
7
have you ever heard of Nerddinner.com? that website has been created with ASP.NET MVC an it is open source on codeplex.
你听说过Nerddinner.com吗?该网站是使用ASP.NET MVC创建的,它在codeplex上是开源的。
Here is the release that has razor and MVC3 version of it;
这是有剃刀和MVC3版本的版本;
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
ASP.NET MVC 3:使用Razor进行布局和部分
ASP.NET MVC 3:使用Razor的隐式和显式代码块
ASP.Net MVC 3 RC 2应用程序在共享主机环境中的应用而不会绊倒托管公司
ASP.NET MVC 3:使用Razor进行布局
Razor发布了Phil Haacked博客的帖子
#2
3
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 * 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..
Razor语法并不是您所需要的,您也希望使用MVC 3获得最佳模式和实践。遗憾的是MVC3上有零书,只有网络参考从小到大不等。此时,您必须使用*并不断使用谷歌并设置一个日期范围来搜索过去一个月左右。此外,在mvc 3剃须刀等设置谷歌“警报”..
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.
我发现复数的例子,nerddinner,Silk(MileageStats),MvcMusicStore,ProDinner和其他几个“有用”而不是一个是(或可能是)每个领域的最佳实践。每个人都尝试着“快乐的道路”,但许多例子都是从这个角度转向的。许多例子都在做各种IOC容器。有些人使用Unity其他结构图,其他人使用Ninject。根据技能水平和现有知识,它可能是压倒性的。
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.
就个人而言,我正在使用带有Oracle 9的vs / 2010 / mvc3的新项目......因此,大多数示例都不是非常有用,因为与EntityFramework的数据库集成使用datacontext / IQueryable非常棒,但是在测试版中使用Oracle EF,并且sprocs甚至没有使用带有EF的Oracle 9(每次尝试,以及来自Oracle培训师的电子邮件响应等)。我最终不得不去旧学校并改造ADO.NET并转换为List ...并使用IEnumerable。因此,在我的环境中使用Oracle时,许多在演示项目中的模型/控制器/视图中易于使用的东西都是徒劳的。
#3
2
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.
嗯......我在家里使用MVC 2和工作以及MVC 3,我真的没有在Razor语法的最佳实践方面找到太多差异。如果我想阅读有关使用Razor功能的方法,我通常只阅读ScottGu或Phil Haack的博客。不确定这对你有什么帮助,但我在画一个空白。
#4
-1
Please check below link for example with good presentation. http://dotnetautor.de/blog/content/binary/Windows-Live-Writer/32ee537b2c00_E16A/MVC3.pdf
请查看以下链接,例如良好的演示文稿。 http://dotnetautor.de/blog/content/binary/Windows-Live-Writer/32ee537b2c00_E16A/MVC3.pdf
#1
7
have you ever heard of Nerddinner.com? that website has been created with ASP.NET MVC an it is open source on codeplex.
你听说过Nerddinner.com吗?该网站是使用ASP.NET MVC创建的,它在codeplex上是开源的。
Here is the release that has razor and MVC3 version of it;
这是有剃刀和MVC3版本的版本;
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
ASP.NET MVC 3:使用Razor进行布局和部分
ASP.NET MVC 3:使用Razor的隐式和显式代码块
ASP.Net MVC 3 RC 2应用程序在共享主机环境中的应用而不会绊倒托管公司
ASP.NET MVC 3:使用Razor进行布局
Razor发布了Phil Haacked博客的帖子
#2
3
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 * 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..
Razor语法并不是您所需要的,您也希望使用MVC 3获得最佳模式和实践。遗憾的是MVC3上有零书,只有网络参考从小到大不等。此时,您必须使用*并不断使用谷歌并设置一个日期范围来搜索过去一个月左右。此外,在mvc 3剃须刀等设置谷歌“警报”..
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.
我发现复数的例子,nerddinner,Silk(MileageStats),MvcMusicStore,ProDinner和其他几个“有用”而不是一个是(或可能是)每个领域的最佳实践。每个人都尝试着“快乐的道路”,但许多例子都是从这个角度转向的。许多例子都在做各种IOC容器。有些人使用Unity其他结构图,其他人使用Ninject。根据技能水平和现有知识,它可能是压倒性的。
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.
就个人而言,我正在使用带有Oracle 9的vs / 2010 / mvc3的新项目......因此,大多数示例都不是非常有用,因为与EntityFramework的数据库集成使用datacontext / IQueryable非常棒,但是在测试版中使用Oracle EF,并且sprocs甚至没有使用带有EF的Oracle 9(每次尝试,以及来自Oracle培训师的电子邮件响应等)。我最终不得不去旧学校并改造ADO.NET并转换为List ...并使用IEnumerable。因此,在我的环境中使用Oracle时,许多在演示项目中的模型/控制器/视图中易于使用的东西都是徒劳的。
#3
2
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.
嗯......我在家里使用MVC 2和工作以及MVC 3,我真的没有在Razor语法的最佳实践方面找到太多差异。如果我想阅读有关使用Razor功能的方法,我通常只阅读ScottGu或Phil Haack的博客。不确定这对你有什么帮助,但我在画一个空白。
#4
-1
Please check below link for example with good presentation. http://dotnetautor.de/blog/content/binary/Windows-Live-Writer/32ee537b2c00_E16A/MVC3.pdf
请查看以下链接,例如良好的演示文稿。 http://dotnetautor.de/blog/content/binary/Windows-Live-Writer/32ee537b2c00_E16A/MVC3.pdf