Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Images in Razor Class Library

Is it possible to use images and other file types such as css/js/etc. in a Razor Class library? I'm having an issue trying to get the images and css in the Razor Class Library to show up in a .Net Core 2.1 MVC application.

We used to use the File Provider and a C# class library but I feel like the Razor Class Library should be able to accomplish this now by simply adding a reference to the library in a project.

like image 206
JTester Avatar asked Jun 26 '18 22:06

JTester


People also ask

What is the difference between Blazor and Razor?

Blazor is a framework that leverages the Razor components to produce dynamic HTML. The biggest difference between Razor and Blazor is that Razor is a markup language with C#, while Blazor is the framework that lets you run C# code and use the Razor view engine in the browser.

Can you use MVC with Razor pages?

You can add support for Pages to any ASP.NET Core MVC app by simply adding a Pages folder and adding Razor Pages files to this folder. Razor Pages use the folder structure as a convention for routing requests.

What can the @page directive do in a Razor page?

@page makes the file into an MVC action, which means that it handles requests directly, without going through a controller. @page must be the first Razor directive on a page. @page affects the behavior of other Razor constructs. Razor Pages file names have a .


1 Answers

  • make wwwroot folder on razor class library project and inside it images folder and insert your images on it to invoke the image on view component or out side project you need to make the path like this
  • src="_content/rclProjectName/images/ajax-load.gif"
  • link https://learn.microsoft.com/en-us/aspnet/core/razor-pages/ui-class?view=aspnetcore-5.0&tabs=visual-studio
like image 194
Ahmed Adel Avatar answered Oct 07 '22 21:10

Ahmed Adel