razor

ASP.NET MVC View Engine Comparison

EDIT: added a community wiki answer to begin capturing people's experience with various View Engines. Please respectfully add any experiences you've had. I've been searching on SO & Google for a breakdown of the various View Engines available for ASP.NET MVC, but haven't found much more than simple high-level descriptions of what a vi...

ASP.Net MVC Razor View Engine

After reading Scott Gu's blog entry about the new Razor view engine for ASP.Net MVC and reading this question comparing the available view engines. Razor seems to address most of the problems with the default view engine. What feature differences would make it a compelling choice for you as a developer? What features are lacking that ...

WebMatrix, ASP.NET Razor, IIS Developer Express, SQL Server Compact Edition - What is Microsoft objective behind these new technologies ?

Recently Microsoft (via Scottgu) has announced some new technologies (WebMatrix, ASP.NET Razor, IIS Developer Express, SQL Server Compact Edition). I think this is something new direction in which Microsoft is trying to move since launching of ASP.NET MVC. I think the clear target of these new moves are Ruby/Python/PHP/.. developers or c...

Where are the Razor assemblies?

I'm playing around with WebMatrix and I'd just like to explore some of the razor stuff behind the scenes... but my Reflector skills (and my brain) are failing me. Does anyone know offhand what assembly I should start looking in (and/or a location for it)? ...

intellisense with razor and VS 2010

Is there any way to get intellisense with razor in VS 2010, I am working on an application with web matrix and launched VS 2010 from WebMatrix. ...

How to import a namespace in Razor View Page?

How to import a namespace in Razor View Page? ...

installing the razor view engine for Visual Studio

I just downloaded and installed Web Matrix beta. I am really liking the razor view engine. Not so much the Web Matrix IDE. Is there any way to install razor view engine for use in the Visual Studio without installing WebMatrix? ...

Can we use Razor on an existing Asp.Net 4 WebSite?

Is it possible to use Razor on an existing Asp.Net 4 WebSite? ...

"Object reference not set to an instance of an object" when initialising multi-dimensional array

I am running the following code on an ASP.NET razor page (cshtml) and am suffering the dreaded "Object reference not set to an instance of an object" problem. Could someone help me out with this problem? The code I'm using is below and the line causing the problem is menu[1][0] = "About"; string[][] menu = new string[5][]; menu[0] = new...

Formatting strings in ASP.NET Razor

I am currently writing a small templating system in ASP.NET to allow users to add content. For example, the user can enter the string (variable type is string). topHeader[x] = "They think it's all over. It is now!"; However, one change that's needed is the ability to add some basic HTML tags within this content, so the following can b...

Razor wishlist - what would you like to be implemented?

Razor view engine looks promising, so I thought it would be good to contribute with ideas and compile a wish-list of Razor features while the development is just in preview stage. What are the features you miss today in Spark, Webforms, or early Razor release and would like to be implemented in Razor? UPD: Why close this question??? Wh...

Emitting unencoded strings in a Razor view

As ScottGu says in his blog post «by default content emitted using a @ block is automatically HTML encoded to better protect against XSS attack scenarios». My question is: how can you output a non-HTML-encoded string? For the sake of simplicity, pls stick to this simple case: @{ var html = "<a href='#'>Click me</a>" // I want to emit...

Creating and Simple Class and Calling a Method from a cshtml File

Hello, Could some one give a simple example of creating a simple class with a simple method and calling the method from cshtml file in webmatrix? I am trying to figure out if WebMatrix could be used in an object oriented way that would allow me to take advantage of the razor sytax as a view engine alternative to the MVC framework that I...

Would it be worth to remove the .aspx/.ascx lookup if I don't plan to use them?

Now that MVC 3 Preview 1 here, we can use Razor (.cshtml) view engine. If a view not found, I get this error: The view 'a' or its master was not found. The following locations were searched: ~/Views/Home/a.aspx ~/Views/Home/a.ascx ~/Views/Shared/a.aspx ~/Views/Shared/a.ascx ~/Views/Home/a.cshtml ~/Views/Shared/a.cshtml Would it be wor...

Razor view engine - exception when calling Any Function

Hello, I am trying to convert an existing ASPX page to cshtml format. The original ASPX looks something like this: <% if (!Model.ObjectList.Any()) { %> <tr> <td>No data found</td> </tr> <% } The equivalent Razor version looks like this: @if (!Model.ObjectList.Any()) { <tr> <td>...

how i can write css for individual page of my project who developed in MVC 3

i thing i put something wrong here sorry for that if you confused. i want to put Javascript or Css in the Head of my page [who is render in browser]. when i try to put them then i found that he inside of Body not inside of head tag. i know that i can easily put in head if i not inherit them from master page. but how i can put on my ...

ASP.Net MVC 3 - Html Extensions...

Hey guys I'm playing around with Razor + MVC 3 and have a really simple scenario... Basically I'm trying to create a very basic HTML helper but I'm getting the following exception: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'ScriptCss' and no extension method 'ScriptCss' accepting a first argument of type...

Razor view engine - How can I add Partial Views

Hello, I was wondering what, if it is possible, is the best way to render a partial using the new razor view engine. I understand this is something that wasn't finished completely by the time Right now I am using RenderPage to render the user control: @RenderPage("~/Views/Shared/LocaleUserControl.cshtml",ViewData.Model) The page call...

Razor comment syntax

What is the syntax for server side comment in razor view? Here is the code that I want to comment: /* @helper NavItem() { } */ ...

Is Response.Write() working with Razor?

Is Response.Write() working with Razor? I tried to use @Html.RenderAction but I'm getting the error: CS1502: The best overloaded method match for 'Microsoft.WebPages.WebPageUltimateBase.Write(Microsoft.WebPages.Helpers.HelperResult)' has some invalid arguments ...