Pass Object from one Aspx to another from Javascript

Correct me if I am doing wrong.

I have a Login page which uses a Webservice to process login. In my Login page I use Jquery with JSon to consume the webservice.

After the login is processed I recieve an object and I want to redirect the recieved object to home page.

Let me know how.

Thanks Samuel

Answers


POST redirect the received JSON to server, and deserialize the JSON to your typed object. You can consider keeping the object in your SESSION and access it when required.

UPDATE

put a hidden field in your aspx/ascx page

Once you receive your JSON Data from your service. Just put your response to the hidden field. (USE JQUERY)

$("input[id$=jsonResponse]").val(responseFromService);

On your Page_Load method on your home.aspx

Use JavaScriptSerializer to deserialize your JSON data

JavaScriptSerializer serializer = new JavaScriptSerializer();

LoginData loginDataObject = serializer.Deserialize<LoginData>(jsonResponse.Value);

Now you can consider putting your loginDataObject to SESSION and access through out your application scope

// to store in session
Request.Session["loginData"] = loginDataObject;
// to retrieve from session
LoginData loginDataObject = (LoginData) Request.Session["loginData"];

Need Your Help

Symfony2, ajax, closed session, outdated entity

symfony2 entity sleep

Let's say i call a controller via ajax and do:

PHP turn off warnings in php.ini does not work

php linux directadmin

I have a VPS with linux CentOS with root access and DirectAdmin control panel.