SergSW
SergSW

Reputation: 338

How can I render Razor page from Assembly

UPDATE1

I've added RazorGenerator and etc...

After set custom tools, I've seen generated code for my razor pages.

Added this code in assembly

public class MyAreaRegistration : AreaRegistration
{

    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute("Dictionary_default", "MyDictionary/{Action}/", new { controller = "DictionaryControllerBase", action = "Index" });
    }

    public override string AreaName
    {
        get { return "MyDictionary"; }
    }

    #endregion
}

But when I open page by url /MyDictionary, i see "Unable to find the resource."

NOTE I use in my project MVC3 and Spring.Net


I use one controller (base controller) in another Assembly with razor pages.

In my project I make controller inherited from base controller, just it make some settings. But razor pages I wish to use from assembly.

How can I do it?

Upvotes: 0

Views: 318

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038720

You could the RazorGenerator extension. I have detailed how this can be achieved in the following post. The idea is that the RazorGenerator extension would create a corresponding .cs file for each Razor view and it will update it every-time you make a change to the corresponding view. This way the Razor views will be precompiled in the class library along with their respective controllers and view models. The RazorGenerator.Mvc NuGet will then register a custom virtual path provider which will take care of resolving those views.

Upvotes: 1

Related Questions