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

1
vote
0answers
25 views

Mail service implementation using Razor engine a MailMessage

This is a very basic Mailer service that I put together after finding out that MVC Mailer doesn't play nice with MVC 5. ...
0
votes
1answer
99 views

Bundling JavaScript resources for an MVC app

This is my first MVC app. I'm looking for best practice feedback on how to best bundle the files that I need, the order to bundle them, the placement of the @render ...
7
votes
1answer
6k views

MVC binding list of values to checkboxlist in an efficient way

I have this code which generates and shows list of selectable items that user can post to controller in order to save into database. Model looks like this: ...
4
votes
1answer
95 views

Joining tables with EF

Here is my database: Here is my viewModel: ...
4
votes
2answers
1k views

A set of Razor HTML helpers for disabling elements

I am developing a huge form with a lot of elements in it. The purpose of this form is editing one domain entity. Now, I finished developing the whole form and it just shows the bunch of text boxes, ...
2
votes
0answers
125 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
150 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
121 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: ...
2
votes
1answer
1k 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
734 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 ...
5
votes
1answer
109 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
1k 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 ...
1
vote
3answers
515 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
149 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
1k views
4
votes
1answer
85 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
42 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
142 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
758 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
2k 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
159 views
9
votes
2answers
2k 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
600 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
1k views

Convert looping statement to linq mode

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

Displaying alert from an action

This code works great, but I think it can be reduced. ...
1
vote
1answer
165 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? ...
6
votes
0answers
885 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 ...