curiousDev
curiousDev

Reputation: 437

how to pass xml from controller to other controller in mvc4

I am new to mvc. Exploring the ways to pass value from action method of one controller to other controller. Is this possible to pass xml as value from one controller to other in httppost?

Upvotes: 0

Views: 110

Answers (2)

Harris
Harris

Reputation: 1785

You can use Session, which is available at pretty much any time in a controller, and is very simple to use.

Session["ArbitraryKeyString"] = "Assign any object";
string arbitraryString = (string)(Session["ArbitraryKeyString"] ?? "Session returns null if key not found");

Just be sure to cast it back to the type you need, because it's stored as a Object. You can do this during server calls, since they're all simply external ways to call controller functions, and the values will persist between pages and calls.

Upvotes: 2

coder771
coder771

Reputation: 368

Passing it as a parameter is probably your best option. Try using something like return RedirectToAction(ActionName, ControllerName, RouteValues);.

Upvotes: -1

Related Questions