I am trying to Register a new user according to Taiseer Joudeh's Article: Token Based Authentication using ASP.NET Web API 2, Owin, and Identity
After successfully registered I want to automatically login the user and return token, which I still haven't been able to know exactly how can I do it on Api before actually returning to the client.
Anyway the application call the APi successfully and register the user with no problem (I Debugged the code), it's not breaking anywhere, in fact from the APi it returns the expected results. Now the problem is, suddenly something that was not happening all along, on the client it returns "Failed to load resource: the server responded with a status of 500 (Internal Server Error)". When I further check the returned object, this is what it gives me:
"Error getting value from 'ReadTimeout' on 'Microsoft.Owin.Host.SystemWeb.CallStreams.InputStream'." exceptionType: "Newtonsoft.Json.JsonSerializationExcept
exceptionMessage: "Timeouts are not supported on this stream." exceptionType: "System.InvalidOperationException" message: "An error has occurred." stackTrace: " at System.IO.Stream.get_ReadTimeout() ↵ at Microsoft.Owin.Host.SystemWeb.CallStreams.DelegatingStream.get_ReadTimeout() ↵ at GetReadTimeout(Object ) ↵ at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)"
I'm using angular and from the service it suppose to go to On success but now unfortunately it then lands On error:
authService.saveRegistration(data).then(function (response) {
//On success
if (response.data.status == 1) {
$scope.savedSuccessfully = true;
$scope.message = "You in, Congratulations!";
$("#registerMsg").removeClass("alert-danger").removeClass("alert-warning").addClass("alert-success");
toggleButton("done", "registerSubmit");
$(".spinner").hide();
} else {
$scope.message(response.data.message);
}
},
function (response) {
//On Error
}
This is the object I'm returning from Api, which works fine on all other Api calls.
public class Response
{
public ResponseStatus Status { get; set; }
public string StatusCode { get; set; }
public string Message { get; set; }
public object Content { get; set; }
}
Please help, if you can also how can I login the user on Api.
Thank you