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.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
37 views

Data Table not displaying in Razor Page

I'm encountering an issue with my Razor page where the data table isn't displaying any data. Could someone please assist me in troubleshooting and resolving this issue? The table with the headings ...
Oxhei's user avatar
  • 1
0 votes
1 answer
30 views

ASP.NET MVC Data Annotation validate a group checkboxes

I am new to ASP.NET MVC and working on the form validation. I am stuck with a group checkboxes validation. Basically, I am trying to make the user select at least one hobby in a group of checkboxes. ...
Milacay's user avatar
  • 1,441
1 vote
0 answers
50 views

How to use HttpClient in a Razor component?

I want to create a Blazor component library for my Microservice app and I have an issue on the login.razor component : @inject NavigationManager NavigationManager @inject HttpClient HttpClient @inject ...
Clément GRANDGIRARD's user avatar
0 votes
1 answer
9 views

How to return either Redirect of the same page with model in Rasor?

In OnPost method I have two options Success: I need to redirect to view page. Failure: I need to return the same page with filled model to show errors to the user. What should the handler return? ...
Yola's user avatar
  • 18.6k
0 votes
0 answers
30 views

OperationCancelled Exception not being caught

I have a Razor app where most of the Client pages have Http.GetJsonAsync requests in the OnInitializeAsync. I have found that if I navigate between pages fast enough that OperationCancelled Exceptions ...
Spencer Wagner's user avatar
-1 votes
1 answer
56 views

How to use global styles with blazor css isolation?

I'm using Blazor CSS isolation for a component. My component is MyToolbar.razor and css file is MyToolbar.razor.css. I want to use global icons inside MyToolbar.razor component. How to do that?
AnC Dev's user avatar
  • 149
0 votes
1 answer
69 views

Error when instantiating object from model class

I've hit a snag. On my Summary page I want to pull from a table, YearSummariesStatic, as well as a view, YearSummariesDynamic. I have everything working fine with just the Static table. But I'm ...
Jim Becker's user avatar
0 votes
1 answer
44 views

Blazor Wrap InputCheckbox in Custom Element

I am trying to create a custom checkbox for use in an EditForm using .NET 8. My checkbox initially was implemented using a button which just toggles the value. I was unable to get this to work in an ...
Droidenkiller's user avatar
0 votes
1 answer
45 views

ASP.NET Core Razor - redirecting from a dependency injected service

I'm building a Razor pages website. Users are required to login to access the website. I have a controller behind the login, e.g: [Authorize(AuthenticationSchemes = CookieAuthenticationDefaults....
gbgr's user avatar
  • 13
1 vote
1 answer
50 views

Why can't I use <script> in Blazor Wasm razor file?

I created a new Blazor Wasm project to test this. In Index.razor, I added the code <textarea rows="1" oninput="adjustRows(this)"> </textarea> <textarea rows=&...
Flippowitsch's user avatar
0 votes
1 answer
48 views

Passing a parameter using a class to an Html.ActionLink

I want to pass a parameter to an action link using a class. The action link look like this @Html.ActionLink(pantalla.Descripcion, pantalla.Action, pantalla.Controlador, pantalla.Parametros) The class ...
Félix's user avatar
  • 3
0 votes
1 answer
40 views

Images won't load in asp.net mvc 4

I never upload ASP.NET MVC 4 on Plesk, work with ASP.NET Core 5 MVC. I have to develop a project with ASP.NET MVC 4 due to my boss's order. I don't have any problem with localhost and can run the ...
Reza Paidar's user avatar
0 votes
0 answers
26 views

Upload file from @ondrop event as ByteArray

I am trying to have a div where I can drag and drop a file onto. This file should be uploaded to my backend as a ByteArray and stored in a blob storage. I already have this implementation of uploading ...
spjdev's user avatar
  • 32
0 votes
1 answer
48 views

How to show a message if selected language is not valid

I have a drop-down list to select languages and it works. My question is if a language is selected and doesn't have any information in the database. How do I show a message, saying "No officer ...
cg1323's user avatar
  • 5
1 vote
1 answer
81 views

AJAX returns undefined, failure

I am trying to use the success and failure blocks of the AJAX request. My function is working and I can easily direct to the controller and use my queries to modify my SQL database eg. Everything is ...
Onur Serbes's user avatar
0 votes
1 answer
48 views

Is ASP.NET Core 8 HtmlRenderer thread-safe?

Background: It looks like a new class was added to ASP.NET Core 8, HtmlRenderer, which allows rendering CSHTML to a string beyond the standard use case of rendering cshtml via a request/response. An ...
BenjiFB's user avatar
  • 4,571
0 votes
0 answers
45 views

.NET Azure Authentication/Authoriziation with Security Group

I am new to .NET C# and trying to implement the Azure authentication/authorization with Security Group. I was able to to get the authentication working, but I am not sure how to in-cooperate the ...
Milacay's user avatar
  • 1,441
0 votes
0 answers
20 views

Visual Studio 2022 latest update changed outlining behavior

The most recent updates to VS 2022 have broken my normal outlining. Working in Blazor Server (.razor pages), I used to be able to collapse code tag areas, and it would leave the first line intact with ...
AndyC's user avatar
  • 47
0 votes
1 answer
48 views

How to Conditionally Invoke a JavaScript Function from a Razor View Based on a Separate Controller Method?

I have a separate controller method which builds a HTML table and is created into my Razor view when invoked through an AJAX POST. Please see the controller method snippet below: [HttpPost] ...
X888ARJ's user avatar
0 votes
0 answers
6 views

AspNetCoreGeneratedDocument - On build server this doesnt get included in the DLL

With .Net 6, razor views are compiledinto the main DLL, under the namespace AspNetCoreGeneratedDocument. I have a solution where this works perfectly well locally, but when building from Jenkins, ...
Ethan Schofer's user avatar
0 votes
1 answer
20 views

Passing Query string to the Razor component using [SupplyParameterFromQuery] attribute is not working

Passing Query String to the Razor component using SupplyParameterFromQuery attribute is not working. QueryStringTest.razor @page "/querytest" <h3>Query String Test</h3> <p>...
Naveen's user avatar
  • 139
1 vote
1 answer
80 views

Place order handler not working, redirects me to 404 error page, and the breakpoint doesn't get hit either, why?

[ValidateAntiForgeryToken] public IActionResult OnPostPlaceOrder() { try { if (!_userManager.UserIsGuest()) { int? customerID = _customerManager.GetCustomerId(); ...
mimi's user avatar
  • 13
0 votes
0 answers
37 views

cshtml file has no attached C# file

I have a Razor page with the .cshtml file extension. Register.cshtml @using Project.Models.Auth @model RegisterModel @{ Layout = null; } <!DOCTYPE html> <html> <head> <...
iKingNinja's user avatar
1 vote
1 answer
34 views

Why is my property showing validations even If I didn't explicitly put any [Required] attribute on it?

Why is my model property doing validation for [Required] even I did not explicitly put any of it in my model class? In the forms in front-end if I left the MiddleName input blank or untouched it shows ...
John Phillip Abello's user avatar
0 votes
0 answers
11 views

How can I pass large amount of data (100K-1MB) from Razor Server to Razor Client Page?

I have a Razor server app that is generating a PDF that needs to be passed to the client for printing. I have already worked out the printing part, but need to figure out how to get the PDF from the ...
kpfishon's user avatar
0 votes
0 answers
51 views

Dynamic page not being created (again)

I'm trying to figure out how to overload my Opponents page, such that if I call /Opponents with no arguments I get a summary page, but it I call it with an argument (/Opponents/Centerville) it renders ...
Jim Becker's user avatar
0 votes
0 answers
54 views

I cannot retrieve the name part in the database

I am following a developer but I would like to ask for your help for an issue that I cannot comprehend, when I try to bring the name of the Universities to the University field in my own application, ...
Mehmet's user avatar
  • 23
0 votes
0 answers
48 views

div does not register scolling event

I have a simple div <div class="flex-item middle" id="scrollable-element"> <div class="logo"> <img src=&...
innom's user avatar
  • 867
0 votes
0 answers
35 views

Dynamic page not being created

I am successfully creating my Years pages. When I call /Years/1956 it is creating and rendering the page. Here is my Years.cshtml.cs: using Alpha.Data; using Alpha.Models; using Microsoft.AspNetCore....
Jim Becker's user avatar
0 votes
0 answers
24 views

How do I clean session with a onclick button

This might be pretty obvious or stupid question but I have a button that I want it to logout of a session when pressed, but I can't just do <button onclick="@{httpcontext.session.clear();}&...
Baconn's user avatar
  • 1
0 votes
0 answers
10 views

how to type a Value on a dataGrid blazor to update it?

I'm beginner in coding. I try to update the value of stock_quantity of variations displayed in dxGrid. when i enter the new value for some variations it will be stored in local variable then when i ...
Kaouthar Graja's user avatar
1 vote
1 answer
46 views

How do I debug form data being sent to a controller?

I'm developing a web application in C# from an ASP.NET Core MVC template in Visual Studio 2022, using .NET 6.0. I created a PersonController as an MVC controller with views, using Entity Framework ...
Robert's user avatar
  • 143
0 votes
2 answers
50 views

NullReferenceException after deleting item from database, then redirecting to page showing the list of remaining items

I am getting a System.NullReferenceException: Object reference not set to an instance of an object. when I delete an item from the SQLite database and I redirect to the Index page (which shows the ...
yt10's user avatar
  • 3
0 votes
1 answer
20 views

.Net 8 Intentional Non-Closed HTML Tags

I was wondering if there is a way in a .Net 8 Web App, to indicate that an HTML Tag is intentionally being left without a closing tag. If I have a Header.cshtml as a Partial with <!DOCTYPE html> ...
TheLovelySausage's user avatar
0 votes
0 answers
5 views

How do I assign the output of switch to a varaible in cshtml

I want to assign the result of the switch statement to a variable so I can use it later in the page. How would I do this? switch (realage) { case 0: <span>Account rendered according to N.R.P....
Marc L's user avatar
  • 847
0 votes
2 answers
34 views

HttpContext.User becomes empty on Redirection after Successful Okta Authentication

I am using a .NET 6 Razor page application (Not MVC) where I need to implement SSO Authentication (Okta). For this, I have created a MVC controller inside my Razor page application (I know it's ...
Bluemarble's user avatar
  • 1,941
0 votes
2 answers
41 views

Binding dynamically generated form inputs to viewModel

so I have been developing a web application with .NET 6. I have a form, which has a button that allows generating as many input rows as user wants. I tried to bind it with view model. @model ...
klaudiaRajs's user avatar
0 votes
1 answer
29 views

Passing Array from datatables.net JavaScript to asp.net Razor pages

I'm using Visual Studio 2022 asp.net Razor pages project and trying to pass an array from a DataTables.net table of selected records back to .cshtml.cs OnPostRemove. It appears that the array is being ...
confusedUser1's user avatar
1 vote
1 answer
121 views

Blazor tutorial: @onclick event doesn't work in new razor components

I am very new to Blazor, and I'm following the blazor-workshop tutorial. I'm on .NET version 8.0.100 I created the sample project with the counter component, played a bit with that and everything I ...
Gautzilla's user avatar
0 votes
0 answers
40 views

Blazor doesnt resolve dependencies of a Razor Class Library

My current Project has a main Blazor an UI-Component in a Razor Class Library. In this component I am trying to use a UI-Library called Radzen. So the line of dependencies would look like this: Blazor ...
Joschi Stock's user avatar
0 votes
1 answer
93 views

Show default date on "Input Type Date" in Razor Page, ASP.NET Core 6.0 web app

I have a Index page and link to the Search page. I want when running the page Search to display today's default date as "16/11/2023", but when selecting another date like "15/11/2023&...
Nguyen Duy Nhan's user avatar
0 votes
1 answer
10 views

Razor pages hosting on nginx reverse proxy not showing after dotnet publish

I have an Ubuntu VPS running nginx that reverse proxies my Razor pages. So far the site loads at https but when i edit the index.cshtml file, running dotnet build and publish and restarting service ...
garu525's user avatar
  • 11
0 votes
0 answers
14 views

AutoFac cannot resolve Microsoft.AspNetCore.Http.ISession in my integration test with mediatr

I want to write an integration test for a request send via mediator. Therefore I somehow need to resolve all necessary dependencies. Here is what I do: public class GetCheckoutRequestTests { [Fact]...
D.Dave's user avatar
  • 77
0 votes
1 answer
24 views

How to connect the model to the local Microsoft database? (C# Razor MVC structure - MVS editor)

(self learning here) I'm trying to make a simple website where users can request to change their passwords. There is a page for users' input. I want their input to be stored into the database. I made ...
Monalisa's user avatar
0 votes
1 answer
36 views

How to enable collapsible outlines for razor pages in VS2022

I've been working on learning and using ASP.NET Core Razor MVC in VS2022 and I finally found something that's really been bothering me. I am unable to collapse the sections of a Razor Page to make it ...
tpm8406's user avatar
0 votes
2 answers
62 views

Razor application 404 page not found

When I start a .Net 5 Razor application with dotnet BaGet.dll It always says 404 page not found. However if I dotnet run it or execute the BaGet.exe file, everything are fine. All these static files ...
Anibal Yeh's user avatar
-1 votes
0 answers
83 views

Blazor doesnt resolve dependencies in Razor Class Library

My current Project has a main Blazor an UI-Component in a Razor Class Library. In this component I am trying to use a UI-Library called Radzen. So the line of dependencies would look like this: Blazor ...
Joschi Stock's user avatar
-1 votes
1 answer
62 views

Asp.net core how to get json value in razor page without ajax call

I receive a json string from the server side that I want to access its values. This string is not received by Ajax call and I want to have its value in Razor Page. In the picture above, two values, ...
topcool's user avatar
  • 2,536
0 votes
1 answer
32 views

Syncfusion ASP.NET Core : how to get value in cshtml after DataBinding?

I am using Syncfusion component in my ASP.NET Core 7.0 project. This is my cshtml markup: <ejs-grid id="userstbl" allowSorting="true" allowPaging="true" ...
topcool's user avatar
  • 2,536
0 votes
0 answers
17 views

.NET Core 7 Dynamic Component using reflection

I have one parent .razor component and one child and in the child I load a dynamic component with parameters.... all ok so far it loads and I can retrieve data from the DB. My issue is I need to call ...
user97492's user avatar

1
2 3 4 5
663