ASP.NET MVC | Two Actions one View
I have two actions Start and Question. And I have two views "Start" and开发者_JAVA百科 "Question". I am would like to continue use action Start with view "Start" and action Question with view "Question", and I want to use one view name in URL for both controllers, this name is Question. It should be like /Controller_Name/Question. How to do this?
UPD. Guys, I am sorry for bad explanation.
I don't understand your clearly, because Controller does not related to view, may be you mean Actionresult or you mean folder which related to Controller.
Method view could take parameter = viewname, in your actions methods you could write:
public ActionResult Start()
{
return View("Start");
}
public ActionResult Question()
{
return View("Start")
}
both methods will render Start.aspx(or cshtml if u using Razor) View
Question is slightly vague but would having one view (Question) and calling a partial (@Html.Partial) which returns the "Start" partial work for you?
精彩评论