Skip to main content

Questions tagged [razor]

Razor is a template language used by ASP.NET Web Pages, ASP.NET MVC (since version 3), and ASP.NET Core. It adds a layer of abstraction above HTML generation. It supports seamless transitions between HTML markup and C# or VB code. Transitions between markup and code are indicated by the "@" sign.

1 vote
6 answers
3k views

"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 ...
Mike B's user avatar
  • 12.8k
11 votes
3 answers
6k views

Can we use Razor on an existing ASP.NET 4 website?

Is it possible to use Razor on an existing ASP.NET 4 website?
Amitabh's user avatar
  • 60.5k
8 votes
4 answers
9k views

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 ...
Kenneth J's user avatar
  • 4,866
786 votes
12 answers
331k views

How do I import a namespace in Razor View Page?

How to import a namespace in Razor View Page?
Amitabh's user avatar
  • 60.5k
5 votes
1 answer
2k views

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.
Rony's user avatar
  • 9,465
4 votes
1 answer
360 views

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 ...
womp's user avatar
  • 117k
5 votes
5 answers
2k views

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 ...
18 votes
3 answers
4k views

How do you set the content type for a WebMatrix/Razor Response?

I'd like to return some XML instead of HTML in my WebMatrix cshtml file? How do you change the content type header?
John Sheehan's user avatar
  • 77.9k
41 votes
6 answers
19k views

ASP.NET MVC Razor view engine

After reading Scott Guthrie'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 ...
Nicholas Murray's user avatar
22 votes
5 answers
14k views

Client Id for Property (ASP.Net MVC)

I'm trying to do a label for a TextBox in my View and I'd like to know, how can I take a Id that will be render in client to generate scripts... for example: <label for="<%=x.Name.ClientId%>"...
Felipe Oriani's user avatar
57 votes
5 answers
70k views

how to access querystring in ASP.Net MVC View?

How do I access the querystring value in a View?
Fraz Sundal's user avatar
  • 10.5k
134 votes
14 answers
76k views

Get Current Area Name in View or Controller

How do you get the current area name in the view or controller? Is there anything like ViewContext.RouteData.Values["controller"] for areas?
user202448's user avatar
  • 2,562
2 votes
1 answer
2k views

How can I validate a multiselect in MVC2 form?

This seems like a really basic scenario, but I think it doesn't have a happy ending. I have a simple project class: public class Project { [Required(ErrorMessage = "Project title is required")]...
Roger Rogers's user avatar
7 votes
3 answers
6k views

How do I find out the error count in a ASP.NET MVC View?

I want to format the title of my Validation Summary using a string something like: "There are {0} errors on this page." How do I find out the number of errors without doing it in the controller and ...
Oundless's user avatar
  • 5,475
145 votes
11 answers
156k views

MVC which submit button has been pressed

I have two buttons on my MVC form: <input name="submit" type="submit" id="submit" value="Save" /> <input name="process" type="submit" id="process" value="Process" /> From my Controller ...
Coppermill's user avatar
  • 6,754

15 30 50 per page