c# - Why was the web service task canceled and how do I find out? -


when i'm trying log in website using online web service wrote, don't see happening @ all...

i should point out works 100% when run localhost.

in login:

    private async task dologin(string emailaddress, string password)     {         using (var client = new httpclient())         {             client.baseaddress = new uri(serviceurl);             client.defaultrequestheaders.accept.clear();             client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/json"));              user u = new user() { emailaddress = emailaddress, password = password };              httpresponsemessage response = await client.postasjsonasync("api/user/login", u);             if (response.issuccessstatuscode)             {                 u = await response.content.readasasync<user>();                 if (u.role.rolename == "admin")                 {                     generatecookie(u);                 }                 else                 {                     throw new invalidoperationexception("your user account not permitted access website");                 }             }             else             {                 throw new invalidoperationexception("the email address or password entered incorrect.");             }         }     } 

during execution, doesn't past postasjsonasync await although response (as taken fiddler):

{"title":"user login","message":"error actioning request: [ task canceled. ]\r\n","error":"system.threading.tasks.taskcanceledexception: task canceled.\r\n @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)\r\n @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task)\r\n @ system.runtime.compilerservices.taskawaiter`1.getresult()\r\n @ ortundadmin.controllers.homecontroller.\u003cdologin\u003ed__4.movenext() in r:\users\logan\documents\visual studio 2013\projects\backup\ortundservice\ortundadmin\controllers\homecontroller.cs:line 66\r\n--- end of stack trace previous location exception thrown ---\r\n @ system.runtime.exceptionservices.exceptiondispatchinfo.throw()\r\n
@ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)\r\n @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task)\r\n @ system.runtime.compilerservices.taskawaiter.getresult()\r\n @ ortundadmin.controllers.homecontroller.\u003clogin\u003ed__0.movenext() in r:\users\logan\documents\visual studio 2013\projects\backup\ortundservice\ortundadmin\controllers\homecontroller.cs:line 38"}

this formatting tells me went wrong on service (see httppost below) it's vague - "task canceled". why? how find out?

    [httppost]     [route("~/api/user/login")]     public httpresponsemessage login([frombody]user source)     {         try         {             user requesteduser = db.users.include("role").firstordefault(x => x.emailaddress == source.emailaddress);              if (requesteduser != null && hashing.validatepassword(source.password, requesteduser.password))             {                 return request.createresponse(httpstatuscode.ok, requesteduser);             }             return request.createresponse(httpstatuscode.notfound, "incorrect username or password");         }         catch (exception ex)         {             return reporterror(ex, "user login");         }     } 


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -