Writing/outputting HTML strings unescaped

I've got safe/sanitized HTML saved in a DB table. How can I have this HTML content written out in a Razor view? It always escapes characters like < and ampersands to &amp;.

How do I output xml with ASP.NET razor?

Hi I'm trying to return a view that is xml, meaning the content type will be "text/xml", and the view is using ASP.NET MVC razor. Another post...

"The name 'HTML' does not exist in the current context" in MVC 3 Views

I´m starting to use "MVC 3" but I´m facing some little problems. In my Views, when I code something like this: @if(Request.IsAuthenticated) { <text>Welcome...

Writing HTML code inside variable in ASP.NET C# and Razor

I'm new in ASP.NET C# and I have problems with some things. In PHP, I can store HTML code inside a variable, for example: $list = "<li>My List</li>"; echo "<ul>{$list}</ul>"; // write <ul><li>My...

Runtime error: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0

I tinkered with my ASP.NET MVC4 packages via NuGet, and now System.Web.WebPages.Razor v3 won't load. Sometimes other packages won't load either. My coworker runs the solution without any trouble,...

Get the selected Node from a jstree

I am trying to get the selected Node from a jstree. This is the code in the View <div id="divtree" > <ul id="tree" > @foreach (var m in Model.presidentList) { ...

how to assign a value to mvc tempdata using jquery

I know how to get MVC TempData value using JQuery, but here I am trying to assign some value to TempData using JQuery. Is this possible to assign value to MVC TempData by using JQuery? I am using...

What is the reson behind using $("form").removeData("validator") & $("form").removeData("unobtrusiveValidation"); inside partial view

I am reading the following example link about displaying a partial view inside a popup menu. but i have noticed that inside the partial view the author uses the following code at the end of the...

AJAX Form Post - Not Passing Data

I have a form that that is not being passed to my controller. It is hitting the controller method, but fails in passing any parameters, 'jsonString' is always NULL. ** Note: I have also tried...

Object reference not set to an instance of an object in _Layout.cshtml after updated packages

The project was running fine until I updated all NuGet packages via NuGet Manager(I was trying to get the latest OWIN packages). This error is in the _Layout.cshtml and I have not touched on it...

Call Method from View on Button click without reload

I haven't found a solution for my problem. I am using asp.net mvc. In my View I am trying to call a Method, on a Buttonclick. This is how the button looks like at the moment <button...

Prevent "Scan new Card" on chrome

On the Payment page, we have text field for Credit card number. When the field is selected on android phone through chrome browser, it brings up "Scan new card". How to prevent this pop up? Any idea?

How to get claim inside Asp.Net Core Razor View

I did it in my rc1 project like: User.Claims.ElementAt(#).Value But after I switched to rtm it wouldn’t work anymore. When I debug the Razor view the object looks the same but User.Claims is...

ASP.NET Core redirecting to the same page after submitting a form with HttpPost method

I am developing a web application using ASP.NET Core 2.0. First of all i have a main view called NewOrder.cshtml: @using Microsoft.AspNetCore.Mvc.Rendering @using...

How can I lint cshtml files with vscode?

As a frontend developer, sometimes I have to edit projects that are written in .net mvc and I have to edit cshtml files. I'm using htmlhint extension for vscode (which is perfect to prevent syntax...

AddDbContext not working in ConfigureServices of ASP.NET Razor 2.2

I reversed a sql server database into their respective classes and context, and all this appears to of worked fine. In the min context class, there is a line of code pointing to the connection...

How to call Vue components in my .cshtml pages?

I have a ASP.NET Core MVC project in conjunction with Vue.js. I am only using Vue.js to make my pages reactive. My goal is to create a main vue instance based on a div in the _layout.cshtml file...

Blazor Server - 'Code Behind' pattern: OnInitializedAsync(): no suitable method found to override

I have a Blazor (Server) application which runs perfectly fine, and which adheres to all rules set by Microsoft.CodeAnalysis.FxCopAnalyzers and StyleCop.Analyzers. A heavily cut-down razor page is...

Get Current User in a Blazor component

I'm starting a new site with Blazor and Windows Authentication and need to identify the current user viewing the page/component. For a Razor Page, the current user name can be accessed with...

Blazor renders components but immediately fails to connect

I've followed the documentation (and a number of blogs) for adding blazor components to a razor pages app. The razor page is rendering the components perfectly, but then immediately get 'trying to...

How to seamless switch between Blazor Serverside and WebAssembly?

So as we know Blazor is pretty cool. However the 2 versions each have their pros and cons. WebAssembly takes a long time for first load and Serverside consumes resources (connection ports and...

Getting NullReferenceException on IIS Express while running from Visual Studio 2019

I am trying to do CRUD operation on a table from a database (Oracle18c hosted on remote server)- "Items" which has item and UnitWeight as columns. This is my first ASP.NET project. Just following...

Blazor equivalent to @Url.Action or @Html.ActionLink

In ASP.NET MVC, whenever you havea controller and an action in it, you could dynamically generate a link to it in a razor page like: Url.Action("ProductController", "Index", new { id = "123"...

Can I specify the default option for an "asp-items" list directly in the .cshtml?

I have an ASP.Net Core form like this: <div class="form-group" id="DW_Q30_div"> <label>@Questions.Q30*</label> <select asp-for="Answers.Q30"...

Wexbim Files in Razor Pages

I am working on a razor pages project that needs to view IFC files, so I converted the IFC file into Wexbim files to use the XbimWebUi library. My problem is when I use the Wexbim file from...

android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify

After upgrading to android 12, the application is not compiling. It shows "Manifest merger failed with multiple errors, see logs" Error showing in Merged manifest: Merging Errors: Error:...

Visual Studio 2019 version 16.11.0 - error CS1576: The line number specified for #line directive is missing or invalid

Since updating to Visual Studio 2019 version 16.11.0 (today), compilation of Razor MVC views is failing on multiple cshtml files in multiple projects: error CS1576: The line number specified for...

Visual Studio 2022 build failed - but showing no errors

The only strange thing is a warning on the projects, but without any indication of what it is: Any ideas?

Ajax link does not send POST request

I have the following ajax link: @Html.AjaxActionLink(item.Name, "https://test.testspace.space/storage/Data/stream?tokenValue=e58367c8-ec11-4c19-995a-f37ad236e0d2&fileId=2693&position=0", new...

How to create a page navigation partial view?

I have a PaginatedList<T> class inheriting from List<T> in an ASP.NET Core app that my controllers and views use to render paginated content: public class PaginatedList<T> : List<T> { public...