Questions tagged [razor]
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.
20 questions
3
votes
1
answer
164
views
Approaches to Razor without combining C# in HTML
The move to MVC and MVVM has not been easy for me. Combining multiple languages in single pages with inline code is something I find disorienting. I'd like to remedy this by attempting to use Razor ...
2
votes
1
answer
145
views
Using partials to automate form inputs creation
My main focus is having as little duplicate code/files as possible.
Most of the HTML I write is almost identical.
There is already a form template which holds the form and several necessities. That ...
1
vote
0
answers
241
views
ASP .NET Core 6 - .razor components - Routing
I come from a background in ASP.NET MVC 5 on .NET 4.8.
I've been trying to wrap my head around the new razor pages, and can't seem to get routing to work, or understand it, even.
I don't want to use ...
2
votes
2
answers
2k
views
What's the better way to do MVVM with a number of very similar view models?
An important view in our application is a big table of entities. For the purposes of this question I'll use an analogy for our entities - so let's say it's vehicles. There's half a dozen different ...
0
votes
0
answers
1k
views
add web api endpoint, which return html from view
I have ASP.NET 5 Web Api and need to do the following task:
Add endpoint, which get cshtml page and return generated html, so it should do the same what is does razor view engine.
What is better way ...
1
vote
1
answer
78
views
Does it make sense to use reflection or to hard-code controller parameter names in JavaScript?
So I have made a pull request to change this code:
//Controller:
...
[HttpPost]
public ActionResult Unauthorize(int userID, int permissionID)
{
...
0
votes
0
answers
411
views
Is it the right pattern for Razor Pages' private methods to return IActionResult to handler?
Is this a good code pattern in ASP.NET Core Razor Pages, for private methods to return IActionResult to the calling handler?
// Public handler
public IActionResult OnGet()
{
var result = ...
13
votes
4
answers
10k
views
Should it be a claim, a role or a policy?
The distinction between roles and claims is that roles describe a set of users and claims describe a property of a user. So there can be a role "Administrator", but there can also be a claim "...
1
vote
1
answer
116
views
What is the best way to implement model property authorization in an ASP MVC?
We have an MVC application that has very granular and configurable authorization. We currently have been using the authorize attribute against our controllers and controller functions.
The next ...
0
votes
1
answer
122
views
Best Approach to have a shared view
I have a website where I want to have a partial view on the page that contains a Singleton service.
I am trying to do this with Razor Pages, and have tried Partial Views and ViewComponents, but ...
7
votes
1
answer
4k
views
Why use Razor Syntax?
Was doing some reading today about Razor Syntax with MVC Framework and was wondering why would/should I use Razor? What benefit does it provide over doing the same thing in the code behind and/or ...
1
vote
0
answers
731
views
Top Menu bar driving a sidebar sub menu
I have an application written is C# ASP.NET MVC 4 with Razor views.
I am a bit stuck on my menu structure.
As per the image above, one can see that there is a Top Menu and a Side Menu.
The standard ...
23
votes
4
answers
11k
views
If MVC is "Separation of Concerns" then why was Razor Syntax introduced?
My question is related to MVC design pattern and Razor Syntax introduced by Microsoft.
While learning MVC design pattern I was told that the idea is based upon a principle known as Separation of ...
0
votes
0
answers
975
views
Parsing Razor-style Templates
I want to build a template engine (ITT not another template engine...) based on Razor.
I've been at it for quite a long time not getting anywhere and quite frankly I'm at my limit. I've tried rolling ...
6
votes
2
answers
21k
views
In ASP.NET MVC/Razor, how to add initializer JavaScript to a "control"?
Actually, I already have at least 3 different solutions for the problem, I just don't like any of them for various reasons.
In ASP.NET MVC/Razor, there are no controls anymore, in the sense as they ...
-2
votes
3
answers
867
views
Host an MVC 3 with Razor syntax app on old server [closed]
I just started a new job, I have to create a web app for them and host it on their intranet on an Windows 2003 R2 server with SQL server 2008.
As said in the question, I'll work on a MCV3 with Razor ...
1
vote
1
answer
212
views
Primer on moving around in MVC
It was suggested on my Stack Overflow question that this might be better suited to this site, so I'm cross-posting it.
I'm working on my first ground-up build of an MVC site. I have a collection of ...
0
votes
1
answer
2k
views
Get/Post Controller Logic Best Practice
In an ASP.NET MVC project (Razor), I have a Get request, which loads two properties on a model, dependent on the property passed into the action method. So if the parameter has a value, the Group ...
0
votes
3
answers
4k
views
How to build MVC Views that work with polymorphic domain model design?
This is more of a "how would you do it" type of question.
The application I'm working on is an ASP.NET MVC4 app using Razor syntax.
I've got a nice domain model which has a few polymorphic classes, ...
9
votes
6
answers
9k
views
Is Razor or XSLT better for my project? [closed]
I'm in the early stages in the design of a system that will essentially be split into two parts. One part is a service and the other is an interface with the service providing data through something ...