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.
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
520 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 ...
6
votes
3answers
152 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 ...
5
votes
1answer
126 views
5
votes
1answer
565 views
5
votes
0answers
705 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 ...
4
votes
3answers
127 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:
...
4
votes
2answers
778 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.
...
4
votes
1answer
74 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.
...
3
votes
1answer
121 views
Replacing div if there is any validation error connected with the div value
I have an input group:
...
3
votes
1answer
71 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 ...
3
votes
1answer
555 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 ...
3
votes
0answers
34 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?
...
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.
...
1
vote
3answers
95 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 ...
1
vote
4answers
119 views
1
vote
1answer
132 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?
...
1
vote
1answer
39 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
68 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
85 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 ...
0
votes
0answers
19 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 ...