ASP.NET MVC return a different view

I have a view which contains a form, the form posts and the data gets processed etc, then I want to return the view Index, so return view("Index");

however this will then complain about my ViewData not existing, I get the feeling that the controller code under Index() isn't being processed which adds the list it requires to the ViewData, anyone know what's wrong?


edit: Apparently it's done to prevent recursion.. in which case, I'm lost as to what to do without repeating all my ViewData stuff both Controllers


I think you should have two actions: one that processes the form submission, and another one that collects data for the view. Once the form has been processed, you call return RedirectToAction("Index") and you are done. I hope I understood what you meant by this.

If your Index method on the controller does a return View("Index"); then just call the Index method with any parameters it requires. Then the method will populate the ViewData reuired by the Index View.

Need Your Help

AS3 FLVPLaybackCaptioning Component Displaying Images?

flash actionscript-3 flash-cs3 flvplayback

I am using the FLVPlaybackCaptioning Component to display captions for a video. We've built a player that uses a FLV file hosted locally or streamed from the server to show captions for a video, a ...

I'm getting LinkageError: bad major version at offset=6, while deploying app on S60 Emulator

java java-me linker-errors midp s60

I actually developing J2ME project using S60 SDK, my project gives me the error,