Asp.net MVC - Displays a partial view from an area

I created an area that will handle our some common things in all our development products, just like magazines, HTML helpers, etc. Inside the area, I have a partial view that I'm trying to reference outside the area. I registered the area with

public class Routes : AreaRegistration
{
    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "Common_default",
            "Common/{controller}/{action}/{id}",
            new {
                controller = "Account",
                action = "Index",
                id = UrlParameter.Optional
            });
    }

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

And now in a normal project, I'm trying to reference a view in the MvcCommons area ...

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2>TestGrid</h2>

<% Html.RenderPartial("jQGridTable", ViewData.Model); %>

But I always understand that the submission was not found. Previously, when I created the MVC Commons project, I got viewing errors, but errors told me that it was viewed both in the area folders and in the default view folders. This time I get only the default folders. Is there any way to do this?

Thanks everyone!

+5
3

, , , , Html.RenderAction(), - Html.RenderAction("action", "controller", new { area = "Area", model = ViewData.Model }).

, .

.

+5

ViewEngine ( ) , . , ViewEngine. , : ViewEngine

0

, RenderPartial .

, View/ , , .

, , View/Shared. , , , , .

You can call a region when you want to visualize actions, not partial ones — which then change the context of the current action to the action you are invoking, thereby allowing you to then return views in that region.

0
source

All Articles