Skip to main content

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.

9,062 questions with no upvoted or accepted answers
14 votes
2 answers
11k views

Why can't Visual Studio preview MVC Razor View (.cshtml) pages similar to asp/aspx pages?

I enjoy working with ASP.NET MVC 3 using the Razor view engine, but am embarrassed to admit that not having the ability to preview the pages (.cshtml) in the Visual Studio designer negatively affects ...
Rich Bianco's user avatar
  • 4,174
11 votes
1 answer
5k views

Is it possible to use ASP.NET Core Web API and Views with Razor and get Intellisense?

If I build a Web API Project in Asp.Net Core 1.x, and I want to build the front-end in the same Project or Solution, is it possible to create front-end pages and use Razor with Visual Studio's ...
johnny's user avatar
  • 19.6k
10 votes
3 answers
1k views

Visual Studio formatting doesn't work with Control + K+D and multiline

I am using Telerik's UI for ASP.NET widgets. Most of these widgets have multiple configuration options. In .cshtml file i configure these widgets on multiple lines for readability. For example below ...
LP13's user avatar
  • 33.1k
10 votes
0 answers
444 views

Using Razor and Nancy together causes Visual Studio 2015 to incorrectly report errors in .cshtml files

I am using Nancy and Razor together to build my web app. I am able to serve up Razor views, and they display totally fine. However, Visual Studio 2015 reports errors on almost every line in my .cshtml ...
Steve Rukuts's user avatar
  • 9,297
10 votes
2 answers
1k views

Is there a way to do an `extern alias` inside a razor (MVC3) view?

Is there a way to do an extern alias inside a razor (MVC3) view? I have two versions of the same assembly (i.e. 1.0 and 2.0) with a type that has the same name and namespace and I need a way to ...
Jesus is Lord's user avatar
9 votes
0 answers
695 views

How to write a DiagnosticAnalyzer for razor files?

My Goal My team decided, that they wanted to incorporate automation to enforce coding guidelines in .razor files. Since we're already using StyleCopAnalyzers, I might implement our own Analyzer to ...
LuckyLikey's user avatar
  • 3,712
9 votes
0 answers
2k views

Import namespace globally in ASP.NET views without @using

In my ASP.NET MVC 5 Application I have all my models in the namespace MyApp.Models. To use the model inside my view, e.g. to tell the view which model he should use with @model UserLoginModel, I have ...
Lion's user avatar
  • 17.5k
9 votes
2 answers
6k views

ASP.NET Razor like WYSIWYG Browser Editor

We have been using asp.net mvc razor technology as a template engine to allow the user to develop razor scripts on the client. we are using this for email template engine. You can see example at ...
Noam's user avatar
  • 862
8 votes
1 answer
3k views

Does anyone know why Visual Studio can't set a breakpoint after the update?

I upgraded the version from 2019 to 2022; But this action caused a problem: I cannot insert breakpoint anymore (.cshtml file),other formats can still insert breakpoints. I tried to modify the debug ...
Dirac's user avatar
  • 101
8 votes
1 answer
3k views

Select2 Dropdown not working after browser back button used

I am currently working on a search page that includes several Select2 dropdowns. The dropdown works great on the first page load, but the issue only occurs when someone searches and then hits the ...
Eli's user avatar
  • 549
8 votes
0 answers
883 views

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 ...
Sam's user avatar
  • 602
8 votes
0 answers
1k views

Compile Razor views into a single assembly

What is the least invasive way of compiling .cshtml views into a single assembly? By "least invasive" I mean something that doesn't require twiddling with Custom Tools, setting esoteric values in ....
Anton Gogolev's user avatar
8 votes
1 answer
640 views

When rendering XML using razor cshtml how do I fix or remove validation in visual studio

I have a cshtml file which generates xml. How do I remove the green squiggles which say Validation (XHTML 1.0 Transitional): Element '....' is not supported.
Myster's user avatar
  • 18k
8 votes
2 answers
2k views

How do I add a new Razor Page Template to Visual Studio in ASP.NET Core 2.1?

I've got the Templates folder in my project hierarchy, and I've been modifying those pretty heavily to speed up my scaffolding workflow. However, some of the objects in my database must persist ...
Louis Ingenthron's user avatar
7 votes
0 answers
2k views

Is there a Storybook.js for .net razor?

In particular I'm using asp.net awesome controls, but if telerik controls work with a 'component explorer' than that setup might be good for me too.
Stephan Luis's user avatar

15 30 50 per page
1
2 3 4 5
605