More On Razor Syntax / Expressions

Share on Twitter

This post gets enough said about how the Razor parser works.

http://blog.andrewnurse.net/CommentView,guid,89b7bd90-52d7-4d49-b87d-4e888f285b4c.aspx

The guy, Andrew Nurse, is the one who wrote the parser!   (from Haack’s note)

 

After reading it and a quick chat with @Haacked on twitter, it seems all your “escape” kind of Razor expressions (that is meaning: when mixing code and text without spaces etc…) will look like @(someCode)someText. This is coming from an example, to escape a C# identifier that’s also a keyword, say “class”, you’d be using @(@class). The @(…) style is the new <%: … %> but only required for escape situations.

 

Also, it seems that switching from being equivalent to <%: … %> to being equivalent to <%= … %> by using some Razor notation is not gonna make it. You need to do it through doing some classes implementing IHtmlString interface.

 

Of course I’m not so sure that’s exactly the case. Anyway, Razor is only available now in WebMatrix mini-IDE, not much MVC love yet (pretty soon).  Just thought it might be interesting…

Share on Twitter
, , ,
Share on Twitter
Similar to the last post, it looks like the best way to continue blogging for me is to copy private company/list emails (when appropriate of course). This is a mail I just sent to .NET list in my company, with slight modifications:

Hey all,

Just in case you have not noticed it already, early last night (before I woke up near midnight our time!) Microsoft released public betas of some new and fancy stuff…

1- IIS Express

Remember when I mentioned it before? A nice alternative to Visual Studio built-in dev server.

Supports SSL and other nice stuff, works even on Windows XP but simulates IIS 7.5, no admin privileges required

2- SQL Server Compact Edition

A file-based database engine, just like SQL Server Express, except that when you develop your website with it, you don’t need it to be installed on the server to get running (or anything else installed)

3- New ASP.NET Pages Syntax code-name Razor

This is a new syntax that is going to replace the old <% … %> ASP-Classic-like style we write ASPX/ASCX pages

It’s going to be mainly for ASP.NET MVC, but watch out, I smell like it’s may reach web-forms also

, , , , , , ,
Share on Twitter

This is something I have posted to a private mailing list before, and thought since I have only fixed number of keyboard strokes to death, I should be sharing it with larger audience…

Before Beginning

imageI know some of the audience of this blog may have not even tried ASP.NET MVC, so, you may need to bare with me for a while ((and those familiar with it just bypass this section please).

In ASP.NET MVC, the request goes to a specific method (commonly known as Controller Action) to handle it (choosing which method/action is based on something called Routing, we don’t care about that for now).

Once the method is executed, typically it ends with calling a page or user control (commonly called a View) to send some markup to the browser. Usually this is an ASPX or ASCX file without code behind. It has some special properties to interact with the data coming from the controller action, and some special shortcut methods to write HTML markup (called HTML helpers).

, , , , ,