ASP.NET MVC - How to route to another controller actionResult

Posted on 2011-05-13
Medium Priority
Last Modified: 2012-05-11
I have MVC2 app split into different areas.

In the root I have a view called verifyCustomer.   I want this view when submitted to go to the controller action DetermineBandResult in the TeamAdmin controller which is in another area of the app.

Like tihs

 <% using (Html.BeginForm("DetermineBandResult", "TeamAdmin", new { id = User.Id}, FormMethod.Post, null))

Now when I submit it says that the view DetermineBandResult in TeamAdmin does not exist.    Do I have to create a view specifically for the action result?   I want it to do some processing then route to another view, so rso really I don't need a view called DetermineBandResult

Is this the correct approach?
Question by:ToString1
LVL 21

Expert Comment

by:Craig Wagner
ID: 35760199
I don't think the problem is with your BeginForm call, it sounds like the problem is in the controller method code. What does it do?
LVL 21

Expert Comment

by:Alpesh Patel
ID: 35768382
Please check page codebehind tag in ASPX page. May it has DetermineBandResult view model in that.

Author Comment

ID: 35783679
ok thanks.

So really what we are saying is that there needs to be a view called "DetermineBandResult" for this to work
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.


Expert Comment

ID: 35783902

when TeamAdminController is placed in another area, i think you need to add the name of that area to the route-values.

Html.BeginForm("action", "controller", new {area="areaname", id=User.Id} ...

Author Comment

ID: 35786885
Yes that is correct.  However I am strill grasping with the concept of

Html.BeginForm("myAction", "controller"}

Does the view "myAction" have to exist?   Can it be an actionresult without a view?
LVL 21

Accepted Solution

Craig Wagner earned 2000 total points
ID: 35787336
Your form is not submitting to a View, it is submitting to a controller action (i.e. TeamAdminController.DetermineBandResult). The controller action is probably then turning around and doing a "return View()". If that is the case, then it is expecting a view under Views/TeamAdmin/DetermineBandResult.aspx. This is why I asked initially to see the controller method.

Alternatively, you can return any view you want by specifying the view name, for example:

return View("SomeOtherView")

Another alternative is to return an ActionResult that isn't a view, for example:

return Redirect("SomeOtherPage.aspx")

Or redirect to a different action, for example:

return RedirectToAction("MyOtherAction")

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month17 days, 11 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question