Views: 12.2K
Replies: 2
Archived
|
Do you have ASP.NET MVC 3 Razor experiences to share?I am absolutely new to MVC 3 and trying learn some details.
I was wondering whether anyone has any real-world experiences to share about the new ASP.NET MVC 3 Razor View Engine. Specifically, what is the learning curve when coming from the traditional ASPX View Engine? Also, what about the .cshtm extensions. Does this affect deployment in any way? Or does the Routing system shield you from this? Finally, the new Master page replacement, called _layout page. How different is that from Master pages? Walt Lynton, Mar 15, 2011
|
|
Reply 1Some additional tips
There are few important tips that may be of help while working with razor. 1. By default all outputs are html encoded 2. @Html.Raw (for outputting string with html tags) 3. <img src="@(model).Path"/> : here model is the model or domain object and to avoid conflict enclose this in parenthesis. "Path is the propery on the model. This makes building dynamic attributes a breeze. 4. <text> hello world </text> : Anything put in a text tag is outputted as it is. i.e. no <text> markup is rendered. This is used for outputting plain text without any markup surrounding it. 5. _viewstart.cshtml : Move you common view code here. Like setting up the layout pages.... 6. @@ : escape @character. : If you need to emil @mysite then prefix it with an @ to escape the special meaning. eg.. @@mysite. Rajesh Pillai, Apr 16, 2011
|
|
Reply 2Presently evaluating for a project. Some answers to your questions 1. Easy to learn (seem odd at first, but you can quickly get comfortable with it). 2. .cshtml has no effect on deployment in any way. 3. Routing work as usual 4. Layout page is different in the sense that certain new way of marking child sections rather than the usual contentplace holder. You may find the following resources helpful./ http://weblogs.asp.net/scottgu/archive/2010/10/22/asp-net-mvc-3-layouts.aspx http://weblogs.asp.net/scottgu/archive/2010/12/30/asp-net-mvc-3-layouts-and-sections-with-razor.aspx Deployment http://www.hanselman.com/blog/BINDeployingASPNETMVC3WithRazorToAWindowsServerWithoutMVCInstalled.aspx Running ASP.NET MVC on a shared hosting server http://weblogs.asp.net/scottgu/archive/2011/01/18/running-an-asp-net-mvc-3-app-on-a-web-server-that-doesn-t-have-asp-net-mvc-3-installed.aspx Here are some code samples http://archive.msdn.microsoft.com/aspnetmvcsamples/Release/ProjectReleases.aspx?ReleaseId=5114 Hope this helps.. I will share my experience as I move along with this. Rajesh Pillai, Mar 15, 2011
|