Sergii
Sergii

Reputation: 749

ASP.NET MVC | Two Actions one View

I have two actions Start and Question. And I have two views "Start" and "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.

Upvotes: 1

Views: 2943

Answers (2)

Antony Blazer
Antony Blazer

Reputation: 705

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

Upvotes: 2

Will Ayd
Will Ayd

Reputation: 7164

Question is slightly vague but would having one view (Question) and calling a partial (@Html.Partial) which returns the "Start" partial work for you?

Upvotes: 1

Related Questions