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.