I have the following in my controller:
public ActionResult Tests()
{
}
public ActionResult Test()
{
}
I would like both to go to the Test.cshtml view when I return. Can someone tell me if this is possible. I know the Test one will by default go to Test.cshtml but what about Tests? How can I direct that to the Test.cshtml?
Alternatively should I keep these as two views and use RenderPartial? If I did that then how can I pass my Model into the RenderPartial view?
Thanks,
Provide view name when returning
It seems you haven’t really checked out method overloads. When returning from controller actions there are several possible overloads that return
ViewResultresult. One of them allows you to provide view name:Html.RenderPartial has overloads too
The same is true about
Html.RenderPartialwhere you can also provide model while calling it. Check its extension methods here.I suggest you check documentation because you’ll understand much more.