D
D
Dmitry Smolyakov2015-10-17 23:42:53
ASP.NET
Dmitry Smolyakov, 2015-10-17 23:42:53

Is it possible to have multiple controllers and one delegate?

How to bind multiple Controller+Model in one template?
Here is the project itself https://github.com/spudro/MySiteLern.git.
I'm trying to use the Controller+Model from Area/Posts in the MySiteLern/Views/Home/Index.cshtml template.
I understand that somehow everything is completely wrong.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
eRKa, 2015-10-22
@spudro

You don't talk like that. Controllers are not used in what you called templates. In your case, this is a view, a view. It is controllers that pass data to the view. In ASP MVC, view templates usually start with an underscore.
In your code, you want to send data from a controller that is in another area to a view that is above. By default, when writing,
the controller will look for a view in its scope with the name of the method, in the View folder. In the area, you don’t have a View folder at all, much less a view named index. Therefore it will throw an error.
If you want to give data to a specific view in your area, then specify the name of the view, if you need a view from another area, then you need to do it differently. Otherwise, the meaning of selecting an area in the project is lost. It is better to follow the link from the view to another area, the link should be indicating the namespace where the controller is located, which in turn will call the view you need, well, or from the controller, pass In general, if on the issue, then several controllers can use one view, but in their area.
By passing the method, controller, route and parameters to it.

V
Viktor Buzin, 2015-10-23
@Buzzz

You can add everything to the ViewModel and put the logic there, that’s basically what they do in the controllers, only throwing out the data, then in the ViewModel we aggregate and update the data and splash it out on the form.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question