Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can we use many controllers to control one view.(this view deals with three data bases),
is t possible,
many thanks.

What I have tried:

still i have only view so i need instructions.
Posted
Updated 4-Oct-16 4:28am
Comments
MayurDighe 4-Oct-16 1:54am    
use "Improve question" widget, and provide more information on where you stuck in programming?
F-ES Sitecore 4-Oct-16 3:58am    
The same view can be used by many controllers, but it's unclear exactly what you're asking, ie do you want a single page request to be handled by multiple controllers? If so that is usually done via partial views.

1 solution

You can have multiple controllers tied to 1 view in at least 2 combinatins

1) Using AJAX you can load partial views (which are tied to their own actions in their own controller...or could be same controller). Those partial views are loaded into a primary view, for example index.cshtml

2) You can use one view and many different controllers that return that view in the traditional request manner. The only thing here is that if you used a strongly typed view your going to have to use the same model in all 3 controllers. You will probably end up using ViewBag here (or something like that).

There may be more, these are the common ones i've seen. I use option 1 primarily.

Now if you start working on this and get stuck somewhere, feel free to come back with a clear explanation of your issue and some relevant code samples and I am sure someone will be happy to help you.
 
Share this answer
 
Comments
T_Sub 6-Oct-16 5:57am    
Thank You Very Much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900