0

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.

1 Answer 1

0

I found the answer:

services.Configure<MvcRazorRuntimeCompilationOptions>(options =>
{
    var libraryPath = Path.GetFullPath(
        Path.Combine(builder.Environment.ContentRootPath, "..", "NameOfRazorClassLibrary"));

    options.FileProviders.Add(new PhysicalFileProvider(libraryPath));
});

Related to this documentation:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.