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

learn more… | top users | synonyms

2
votes
0answers
22 views

Umbraco Macro-Script to grab Contour Form and Node Properties

When it comes to the Umbraco CMS, there are components called "Macro-Scripts" which are essentially a Razor View (.cshtml). They allow you to code a bunch of C# and ...
4
votes
2answers
45 views

Displaying separated multi-line text fields

The following code grabs the HTML-encoded, multi-line content of a text field. It then splits the content on line breaks, and finally displays it with commas as separators. I would like to have this ...
1
vote
1answer
50 views

Formatting MVC 5 Razor link as a string

MVC 5 doesn't seem to like JavaScript that much. I am creating link in JavaScript to a success method in my Ajax call. Razor: ...
1
vote
1answer
104 views

Listing users in Azure Active Directory

The code below is the Index Action from a User Controllers. Basically this code returns a list of users from Azure Active Directory using Azure Authentication Library (ADAL). However I need to show ...
0
votes
0answers
127 views

MongoDB repository, dynamic objects, Razor Templates

I am writing a repository for MongoDB and are looking for some review at its current state. I am looking for ways to improve it without adding complexity. Should I be using a Singelton pattern for ...
3
votes
0answers
38 views

Redirecting a user

When the user clicks the first button ('Back to List' button), I redirect the user to the Employee List page. Can you please review this and suggest if there is any better way of achieving the same? ...
6
votes
3answers
188 views

Monkeying around with Survey Monkey and Asp.Net Mvc

Intro I've been a desktop dev for a long time now, and have never really had to monkey with web development until very recently. I have a need to do some custom integration with Survey Monkey's Api ...
0
votes
0answers
21 views

Generic Razor view Model property validation for Form

I have run into instances where someone would add columns to a table in the database, update the Entity Framework models for our solution, but forgot to update the forms to compensate for the added ...
1
vote
3answers
130 views

Partial view for frequently used drop down lists

I have one input that is needed in many forms, so I created a partial view for that. In the partial view I query the database and generate a drop down list. I just want to make sure, this is the best ...
3
votes
1answer
85 views

Razor view to render simple scaffolding for complex type

After several attempts to follow my intuition that this code can be refactored to something more DRY, I keep hitting road blocks. Hoping someone can see a refactor that might get me going in a nicer ...
1
vote
4answers
142 views
4
votes
1answer
75 views

Generate N pairs of checkboxes and N textboxes

I've written a piece of code, where a pair of checkboxes and a textbox are generated N amount of times. Depending on what's in the DB, the checkbox/textbox may have a default value or are left empty. ...
2
votes
1answer
39 views

Disabling buttons on forms

I have 5 different forms where I am disabling the submit button when a valid form is submitted so the form can only be submitted once. I am using a hidden field on each form to get the form Id. ...
4
votes
3answers
130 views

Make huge view in C# readable and maintanable

I have an application that is using MVC5 with C# and Razor Engine. This view displays a huge table: ...
3
votes
1answer
570 views

Quiz form website

I'm trying to get a good grasp on ASP.Net MVC, Razor and RadioButtons, so I tried to make a quiz to test my skills. I implemented a working quiz form in the following way in Razor (not posting the ...
4
votes
2answers
881 views

Is it “legit” to use a Linq query in a razor view?

I have a Linq query in my razor view like below. Its just getting contacts that belong in the group. ...
3
votes
1answer
124 views
8
votes
2answers
1k views

Feature-based authorization

Feature-based authorization It seems to me that if you rely on roles to authorize a web application it makes it very difficult to render UI or code based on a set of features. This means that each ...
7
votes
3answers
526 views

Ternary extension method

I created the following HtmlHelper extension method for my Asp.Net MVC Razor views because the ternary syntax sucks when you need to use it intermixed with markup. Is there a better way to write this ...
5
votes
1answer
617 views

Convert looping statement to linq mode

I have a model object class like this ...
5
votes
1answer
127 views

Displaying alert from an action

This code works great, but I think it can be reduced. ...
1
vote
1answer
135 views

Passing a true/false value to a model used in a controller

This passes the value of true/false to model which I can use in my controller. How can this be cleaned up? ...
5
votes
0answers
714 views

PowerShell module for formatting objects using Razor

I managed to get something up and running, but I've no idea whether there are better ways to do this. I've spent all morning trying to figure out the best way to use parameters (allowing objects from ...