MVC Rendering (RenderPartial, RenderAction) Html from another MVC application

I work in an environment with many teams that are responsible for specific content on the pages. Each team shares certain information (shared class libraries and master pages), each of which is going to provide different types of content.

Is it possible for an MVC application to do something similar to RenderPartial and pass the model to another Controller / Action MVC application to return the content?

So, the code for this might look like this: ( http://www.mydomain.com/Home/Index )

<% Html.RenderAction("ads.mydomain.com", "Home", "Index", AdModel) %>

Perhaps this is not a good idea, since another thread should rotate on a partial view of the server?

+3
source share
2 answers

In principle, yes, although your question is a bit vague.

Look at the "portable areas" in MvcContrib on codeplex. This method allows individual teams to develop separate MVC applications, which will then be hosted by a central application.

+4
source

No, RenderPartial / RenerAction can only load views that it can access through reflection, and not through HTTP requests to external resources.

MVC "ads.mydomain.com" , Areas, , "". mydomain.com ", , .

AJAX, , , javascript. JSON ​​ , .

( Html.RenderRemote), HTTP- URL-. .

public static string RenderRemote(this HtmlHelper, string url, object model)
{
    // send request to 'url' with serialized model as data
    // get response stream and convert to string
    // return it
}

:

<%= Html.RenderRemote('http://ads.mydomain.com', Model');

, URL, , , URL- .

+5

Source: https://habr.com/ru/post/1764071/


All Articles