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.
razor
33,292 questions
0
votes
0
answers
36
views
JetBrains Rider does not recognize MudBlazor components imported via global:: in _Imports.razor (works in Visual Studio)
I am using JetBrains Rider 2025.3.2 on macOS with a MudBlazor project targetting .NET 8, C# 12. The project builds and runs correctly, and the same codebase works without any issues in Visual Studio, ...
2
votes
2
answers
115
views
Why is the Client drop down list in my .razor file showing the integer value instead of the text value?
As mentioned in the subject line why is my Client drop down list in my razor .razor.cs file showing the value instead of the text? As you can see from the image below the Site drop down list is ...
0
votes
1
answer
131
views
Task List displaying TODO comments as belonging to auto-generated files
I'm working with Visual Studio 2022 v17.14.23 on my very first Blazor project.
I ran into an unexpected behaviour when leaving a TODO comment in a .razor file: as ...
1
vote
1
answer
40
views
Generated Blazor components compile but render nothing when created by a Roslyn analyzer
I am generating Blazor components using a custom Roslyn analyzer.
The analyzer emits fully compiled Razor components (as C# classes that inherit from ComponentBase ...
Tooling
0
votes
2
replies
73
views
How to enable Razor/Blazor LSP support in Neovim using lazy.nvim?
I am currently using lazy.nvim to manage my plugins and csharp-language-server for C# development. While C# files work perfectly,...
0
votes
0
answers
76
views
Simplest / lowest overhead method for including server generated variables in IIS webpages
This is possibly a dumb question.
I have a .NET 8 web application that is entirely service based; the pages themselves are pure static HTML, and all dynamic content of any kind is loaded via fetch ...
Tooling
0
votes
0
replies
39
views
C# style rules defined in .editorconfig are ignored in Razor code blocks
I am setting up an .editorconfig file to enforce certain conventions and code styles.
I have noticed that C# style rules only seem to apply to ...
1
vote
1
answer
97
views
ASP.NET Core MVC : get form text info to a controller
I'm trying to get a form to pass a person's name to a controller, and from there, display that person's LARP character info. Right now I'm only passing the character's name, class, species, and image ...
1
vote
1
answer
68
views
How to fix 2sxc (v20.0.8) AppCode HotBuild compile error — AppCode.dll not generated
I'm having an issue when creating a new view in a 2sxc app (version 20.0.8).
Whenever 2sxc tries to generate the datamodels / compile the AppCode, the HotBuild process fails.
It looks like 2sxc is not ...
4
votes
0
answers
100
views
Embedded Views in ASP.NET Core 10
Previously, in .NET 9 and lower, we could use RazorRuntimeCompiliation to implement embedded views in assemblies.
...
1
vote
1
answer
574
views
Problem with Roslyn configuration on neovim
I've been trying to setup roslyn.nvim with rzls.nvim on my neovim for a while to work with .NET, C# and Blazor. But I've been facing some frustrating problems, I'm using WSL Ubuntu 24.04, a neovim ...
0
votes
1
answer
158
views
Blazor auto render mode prerender flicker problem even though pages use persistence
There are two pages in my app:
Page1.razor (home) and Page2.razor. There is no problem rendering first page. But when I navigate ...
0
votes
0
answers
53
views
TLS issues with ActionMailer.Net [duplicate]
I have an ASP.NET MVC application, that uses the following package
ActionMailer.net
This has been going beautifully for many years, but lately we have been hitting issues with the mail servers we have ...
-2
votes
1
answer
99
views
How to use gorazor and iterate over a slice
I want to use gorazor a viewengine written in go that uses razor-Syntax. They provide an example which i tried to understand and adapt.
What is working
I want to iterate over a slices of movies and ...
-3
votes
1
answer
80
views
Error with onblur, There is no argument given that corresponds to the required parameter 'e' [closed]
I get the error,
There is no argument given that corresponds to the required parameter
'e' of 'AddContributor.OnPayerIdChangedAsync(ChangeEventArgs)'
This is the pertinent area of blazor markup:
<...
1
vote
0
answers
93
views
Visual Studio create new custom Scaffold Item for Razor WebApp
Summary:
I want to create a new scaffold item for Visual Studio in my Razor app so that I do not have to edit every CRUD page to use my custom libraries. I have spent the last 2 days letting ChatGPT ...
1
vote
0
answers
57
views
How to disable the pink Razor feature warnings in Visual Studio?
I'm working on an ASP.NET Core MVC project in Visual Studio 2022.
Lately, I keep seeing these warning messages at the top of the editor:
Feature 'Razor Diagnostics Feature' is currently unavailable ...
1
vote
1
answer
129
views
.razor code not recognized (even in new blazor project)
Opened a blazor project for the first time in a while and suddenly no code or components are recognized (even on newly created projects):
When I hover over components no auto-completion suggestions, ...
3
votes
4
answers
146
views
Why does this Razor code compile even though I reuse the same loop variable name in nested foreach
I am writing a Blazor component and noticed something unexpected. In my Razor code, I use a foreach to loop over a list, and inside the Click event handler of a RadzenButton I declare another foreach ...
0
votes
2
answers
156
views
Blazor Server: Custom 404 component causes RenderFragment<T> error with InteractiveServer render mode
I'm trying to use a custom 404 component in a Blazor Server app with this router setup:
...
2
votes
2
answers
193
views
Build error after adding a TypeScript file to a Razor Class Library project
(With Visual Studio 17.14.13) Steps to reproduce (sorry this is a bit long but these are the fewest steps I could find):
From the command line, create the solution folder:
...
1
vote
1
answer
144
views
Manually added Razor page doesn't render razor component
I started a project as .NET Minimal API - no UI whatsoever. Then I needed to add a visual tool for the API, to show what the service is doing.
For UI I wanted to use Razor pages and components, as it ...
1
vote
1
answer
52
views
ASP.NET Core MVC: How to make simple page with IEnumerable<XML>
I have a simple project where the start page shows a list of books. How to make the same page, but with display as XML?
Controller method:
...
1
vote
1
answer
59
views
.NET Core Razor Page erroneously invoking OnGet when clicking an anchor tag in _Layout.cshtml
I have an ASP.NET Core Razor C# app.
In the _Layout.cshtml file, I have anchor tags to launch various pages in the form of a menu.
Here is an example:
...
1
vote
0
answers
36
views
Want to modify the Middleware in razor page to redirect to SessionExpired Page once application times out
I have following AutoLoginMiddleware in my intranet razor page application and want to modify the middleware to redirect to SessionExpired page purposedly once it times out after 30 min (auth cookie ...
0
votes
3
answers
68
views
dropdown menu item doesn't drop down
I have an ASP.NET Core MVC web application. In _layout.cshtml, I have the following code, but it doesn't drop down in the menu bar it shows "manage" with ...
0
votes
2
answers
120
views
Errors while compiling Razor content
This is a follow up on Cannot compile a Razor document.
I get several errors while compiling a Razor content (not a file). The code is like this:
...
0
votes
1
answer
78
views
Can I change the height of the popup height of TelerikMultiSelect in Blazor?
So I am trying to do what Telerik can do in their code for the Jquery version but it's not working. See below:
I am trying to do a pretty simple just list of strings but there are about 80 of them ...
0
votes
1
answer
65
views
Cannot compile a Razor document
I am trying to compile a Razor document for which I have the contents, not the file.
Here are my steps:
...
0
votes
2
answers
67
views
Dynamically create 1 div per row when viewing page in mobile device
I know there are many questions similar to this, but I'm not sure how to implement in my case.
In my razor page, I have a @foreach loop that creates several divs ...
1
vote
0
answers
58
views
Singleton / cascading scoped service using SignalR hub
I have an app where I want to centralise a notification service. With hardware sending out updates of it current status as it changes.
There are a number of separate components which need to react to ...
1
vote
0
answers
80
views
Blazor InputText binding not updating UI with space string is assigned, but works when empty
I can't figure out why if I assign an empty string in the "if" block, everything works and the string and field are updated.But if I remove the space at the end, also changing the variable, ...
1
vote
1
answer
212
views
Is there a way to partially remove minted highlighting in LaTex?
I am using LaTeX for writing a thesis, including the package minted to highlight code. In my case, it is ...
0
votes
0
answers
44
views
set conditional tooltip on Kendo UI Grid column
The conditional tooltip is not working on kendo UI Grid column.
The following code is not applying the condition for title and instead showing the whole text
...
1
vote
1
answer
88
views
Validation messages not clearing with resetForm() or $("#myForm")[0].reset()
I'm trying to understand how input validation works. In the HTML below, btnconfirm triggers the validation errors and resetForm ...
1
vote
1
answer
79
views
Creating a Razor component from a string
Razor components are normally loaded from .razor files. Behind the scenes, they implement the IComponent interface (or one of its implementations).
What I'd like to ...
0
votes
0
answers
32
views
Is "data-val-required" supposed to display message when required validation fails?
The cshtml for my modal dialog has two input forms. When I click on "Submit" the required attributes for the input forms are working since the ajax call is not invoked unless both inputs ...
1
vote
2
answers
198
views
input forms or class properties with Required attribute not stopping ajax call
This has been a slow step-by-step process for me, but I'm getting there.
My modal popup has two input forms that need to be filled out before the ajax call is executed. I've tried a few options, ...
2
votes
1
answer
78
views
Calling server-side method with AJAX from button in dynamic divs
I'm learning how to call C# code from a razor page with AJAX, so please bear with me.
In the html, I create a container of divs based on a foreach loop. The divs ...
0
votes
2
answers
60
views
Change default width of jquery dialog popup in CSHML?
I've been searching for a way to increase the width of the modal popup in my cshtml, but haven't been able to. I tried the suggestions in this SO question, but none worked.
Here's my code. Doesn't ...
0
votes
1
answer
50
views
Modal popup not showing within foreach divs but is displayed outside of the divs
So I've been learning asp.net core and razor, and it's been awesome. I finally created the div structure bound to my sql data, and that was pretty cool.
My next step is to display a modal popup when I ...
0
votes
5
answers
114
views
Display several cells per row?
I'm learning how to use razor, so please bear with me.
I'm trying to create a simple grid that shows our products. Each row will display several products, and each product will display the name, the ...
0
votes
0
answers
52
views
MudBlazor Drag&Drop between MudTable and MudDropZone
I have the razor page (with MudBlazor) with a MudTable at the top. The table displays . Beneath that, I have a grid of MudDropZones, rooms as columns and roles as rows. I called it . So a person has a ...
0
votes
0
answers
34
views
ASP.NET Razor Send HTTP Request via HttpClient and include JWT Auth Browser cookies
I have a WebApi and Razor frontend project (both using .Net 8.0). I'm trying to learn to implement authentication using JWT and cookies.
As of now it is working well:
Login on my razor website, which ...
0
votes
1
answer
84
views
Razor - Convert DataTable to Array in JavaScript
I have a datatable in Razor Project with rows containing id, name, title, parent, and other fields. I need to bind a JavaScript array dynamically, but I tried this code and got an error. Please help.
...
0
votes
0
answers
56
views
DataTable is always empty in ASP.NET MVC
I am working with jQuery datatables, but the datatable is always empty when the page loads. On inspecting the network tab, the request returns an empty response but when debugging the controller ...
1
vote
1
answer
130
views
I have problem to save new data in database using EF Core in ASP.NET Core
I want to create a test website for recording a company's information. After running the software and entering three data entries, everything goes well. However, after registering the fourth data ...
0
votes
0
answers
32
views
How to treat RazorLight templates as Razor views at build-time for validation, but use RazorLight at runtime?
I'm working on an ASP.NET clean architecture project that uses Azure Functions to send emails. The email templates are stored in Services/EmailService/Template/ with each template using @model to bind ...
0
votes
0
answers
45
views
Blazor/Razor auto formatting identation in Visual Studio
I'd like to customize the way Visual Studio auto formats Blazor/Razor components.
Usually, it formats wrapped tags like this:
...
0
votes
1
answer
74
views
'HttpNavigationManager' not initialized when rendering static HTML
I'm trying to generate HTML to a string from a Razor component. I use the following code to do that:
...