how are you?
I've got a simple question. I have the following msg return in my webservice (asmx):
msg = "~/Paginas/Home.aspx";
row.Add("Retorno", msg);
rows.Add(row);
Context.Response.Output.Write(serializer.Serialize(rows));
return;
I'm using it to validate a login page in AngularJS + HTML5. My question is, how could I get this message on HTML side and interpret it to make the redirect?
Thanks in advance!
It would be better if you send a json object through the wire, something like:
on the server side:
var returnInfo = new { Message = '/paginas/home.aspx' };
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.Serialize(returnInfo);
on the client side:
angular.module('myApp').controller('myCtrl', ['$scope', '$resource','$window'
function($scope, $resource, $window) {
var myEndPoint = $resource('/myEndpoint/Url');
myEndPoint.$get(function(data){
if(data.message){
$window.location.href = data.message ; // if you plan to do a full page refresh
}
);
}
]);
that's the general idea to do it, I hope that helps!
cheers!