0

I'm trying to pass an object from aspx code behind to an web app angularjs controller. Let me explain you the problem.

I 've an aspx application, named app1, this application do login and return a big complex object (json or model).

I've too a angularjs application, named app2, this application must be receive the complex object to map and fill an authentication angular variable .

App1 and App2 are in the same presentation layer.

My problem it's, how can pass an complex object from aspx application to angularjs controller.

//Do login from aspx appplication (app1)
protected void submit_Click(object sender, EventArgs e)
{
    lblResponse.Text = "";

    string requestStr = null;
    string responseStr = null;

    var request = new RestRequest("signin", Method.POST);
    SignInRequestREST signinRequest = new SignInRequestREST();

    signinRequest.Mail = txtMail.Text;
    signinRequest.Password = txtPassword.Text;
    signinRequest.SupplierLogin = true;
    request.AddJsonBody(signinRequest);

    requestStr = request.JsonSerializer.Serialize(signinRequest);
    HttpStatusCode status = HttpStatusCode.OK;
    IRestResponse response = Execute(request, out status, ConfigurationManager.AppSettings["URL"]);
    responseStr = response.Content; //Here it's my object in json encode


    if (status == HttpStatusCode.OK)
    {            
        lblResponse.Text = "Is authenticated";

        //Now, here it's my problem
        //How can pass responseStr to app2?
    }
    else
    {
        lblResponse.Text = "It's not authenticated";
    }
}



//AngularJS controller app2)    
$scope.Init = function () {

        //$scope.userInStorage = SessionStorage.getUser('User');
        $scope.userInStorage = responseStr;

       //but I don't know how catch responseStr here?
    }

Usually, you can do http request from angular, and then catch response.

In this case, aspx must be do the request and angular must be only catch the response.

Any idea? I really appreciate help.

R. Richards
  • 24,603
  • 10
  • 64
  • 64
diegobarriosdev
  • 409
  • 1
  • 6
  • 20

2 Answers2

0

you can use

  1. session state
  2. List item

Query string

Here a link to a similar question where you can find the answers

Kemal AL GAZZAH
  • 967
  • 6
  • 15
0

Your submit_Click method returns void. That means it will never pass anything to your controller. Also you don't have any proper code in your AngularJs controller either to call the aspx method or receive data.

Mickers
  • 1,367
  • 1
  • 20
  • 28