View page from ProjectReference not reflected without restarting main project ASP.Net MVC

Tien Dang 81 Reputation points
2022-02-19T10:44:04.303+00:00

I am building a shared UI - razor page in a Lib project (Visual Studio), the purpose is to add the Lib project as ProjectReference to multiple places. I am stuck at finding a way to reflect the .cshtml changes immediately to the browser without restart the main project, which waits me a lot of time.

services.AddMvc().AddRazorRuntimeCompilation();

Setup line above works when I coded UI in main project, but Lib project doesn't.

More information: .Net5.0, Asp.net MVC, Razor page.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,513 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,152 questions
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 64,081 Reputation points
    2022-02-19T17:12:50.58+00:00

    You need to tell the compilation services the mapping of the class library to the folder that contains the razor files. See section on razor libraries.

    https://learn.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-6.0&tabs=visual-studio

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.