Questions tagged [razorengine]
Antaris RazorEngine is a parsing engine that allows robust templates using Razor syntax.
razorengine
575
questions
-2
votes
0
answers
38
views
.NET 8 render Razor page as string within a C# unit test
I'm working on a ASP.NET Core 8 project with controllers that render .cshtml into a string to send it via e-mail to external persons.
Problem is now within a unit test to run the render method because ...
1
vote
1
answer
33
views
How to conditionally render style attribute in Razor template without causing NullReferenceException?
I am working on a templating project using C# and Razor Engine (Razor Templating Engine). The objective is to create React code using my own JSON definition.
My AppDefinition.json looks like this when ...
0
votes
1
answer
40
views
How to use razor renderer in .NET 6?
In my .NET 4.8 Web API application, I take an externally received HTML formatted string and convert it to a .cshtml file using Razor Engine, then append it to my page with JavaScript. I do this using ...
1
vote
1
answer
18
views
How to redirect link to the controller an avoid the last visited link in Visual Studio MVC project?
I added a controller named Welcome to the sample project created by Visual Studio. This sample project comes with Home and Home/Privacy links. I modified the file _Layout.cshtml to add a link to the ...
0
votes
2
answers
137
views
ASP.NET Core asp-for attribute not working in tag helper
I have a custom tag helper and I want to use the asp-for attribute in it, but it renders something else:
public class FormerTagHelper : TagHelper
{
[HtmlAttributeName("asp-for")]
...
0
votes
0
answers
9
views
How to see which model properties cause problem with RazorEngine
I use RazorEngine to substitute some tags in a text with values from a model. All works fine, when the model is totally populated. But I want it to be lazily populated, meaning only the properties ...
1
vote
1
answer
483
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 ...
-1
votes
2
answers
297
views
My solution to mapping CSS styles to Razor Pages is probably convoluted
I could've sworn there was once a time where the razor engine would automatically apply PageName.cshtml.css style to the PageName.cshtml razor page. I don't know what configuration I was running ...
1
vote
0
answers
498
views
C# RazorLight not working when build in release
I installed in my project RazorLight. It work fine locally, but when I build it in release mode this is the error:
Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' file for ...
0
votes
2
answers
41
views
How to invoke multiple function from string "Mystring.ToUpper().FirstPart(3).Replace("M","Ok") C# .net
In server side want do a nested operation with a string. .It will be in dynamic format. I'm trying with razor engine for this. Any ideas..
Eg: "Mystring.ToUpper().FirstPart(3).Replace("M&...
0
votes
0
answers
130
views
C# ASP.NET Core string expression in a taghelper property
In my tag helper I declared a property like this:
[HtmlTargetElement("tr", TagStructure = TagStructure.NormalOrSelfClosing)]
public class EditTableTRTag : TagHelper
{
[HtmlAttributeName(&...
0
votes
1
answer
42
views
.NET 7 API project can't find images
I began with a standard .NET 7 Web API project that runs fine. I ran into a situation where I need to return a one-off view and I didn't want to create another project to serve views so I added a ...
2
votes
1
answer
431
views
View.RenderAsync() causes Cannot access a closed Stream exception
I'm developing net6.0 MVC app. I use partial view rendering to the string format in my app. I make Ajax request to the app and expect it to form a Json containing rendered partial view as a prop.
...
0
votes
1
answer
80
views
Are there any issues with using Razor as a object-oriented code generator?
I've been experimenting with T4 templates to generate code for classes with methods and attributes. While it's serves my purpose, it's missing some highly desirable productivity features such as ...
0
votes
1
answer
550
views
Add content to every view or component in ASP NET MVC
I'm using ASP .NET Core MVC (views and controllers).
Is there a way to add some additional output to all *.cshtml files using middleware, filter or something similar?
I would like to display the path(...