TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Partial Controller in MVC
Pramod Thakur
Apr 09, 2015
45.9
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
In this article we learn that is it possible to make controller as partial controller in MVC.
Can we make controller as partial ?
Yes, we can make controller as partial.
Lets create a mvc application. Now create a contolller and name it "ABCController".
Now make the controller as partial.
using
System.Web.Mvc;
namespace
HtmlInjectInMvc.Controllers
{
public
partial
class
ABCController: Controller
{
public
ActionResult Index()
{
return
View();
}
}
}
Now add a view and name it Index.
Now add another controller and name it xyzController. In xyzController.cs
using
System.Web.Mvc;
namespace
HtmlInjectInMvc.Controllers
{
public
class
xyzController: Controller
{
public
ActionResult Index()
{
return
View();
}
}
public
partial
class
ABCController: Controller
{
public
ActionResult About()
{
ViewBag.Name =
"Prmaod Kumar"
;
return
View();
}
}
}
Now add a view for xyzController and name it index. Add a view and name it about.
Now run the application.
Output
Hope enjoy this article.
Happy coding :)
Partial Controller in MVC
Next Recommended Reading
Auto Refresh a Partial View of a Page in MVC