How to call the controller from an External File/from reference.
It means we can make an Asp.net MVC project and delete the whole controller folder and only we have view inside that project; all the controller are present in separate project.
So here what we are doing is we have creating a project which fully dedicated to View only; and we have other project where we have all controller for that view.
So how to call that controller in Asp.net MVC project to render view.
To do this we follow bellow steps :-
Step 1:-we need to first create a MVC project and deleted whole controller folder from that project; and the project name is “MVC_View_Project”
step2 :- After that we need to create another project taking the template as class library and named that project is “ControlClassProject”.
step 3:- Then we need to add Asp.Net MVC reference in “ControlClassProject” using Nuget Package manager.
step 4:- Then we need to add a class called as HomeController class inside ControlClassProject and did all the thing what i reuired to render my view which present inside “MVC_View_Project”. (You can find all the code bellow)
step 5:- Then we need to add that ControlClassProject reference to “MVC_View_Project” .
step 6 :- Changed routeconfig.cs file.
You find whole source code in the bellow link :-
Click here to Download Source Code