Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Partial Controller in MVC
WhatsApp
Pramod Thakur
9y
46.6
k
0
0
25
Blog
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
Up Next
Auto Refresh a Partial View of a Page in MVC
Ebook Download
View all
Hands on ASP.NET GridView
Read by 17k people
Download Now!
Learn
View all
Membership not found