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…
Permanent link to this post (175 words, 2 images, estimated 42 secs reading time)
ASP.NET, ASP.NET MVC, MVC, Razor
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
I 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).
Read the full post ... (1802 words, 6 images, estimated 7:12 mins reading time)
ASP.NET, ASP.NET MVC, Microsoft News, Miscellaneous, MVC, Razor