Friday 15 August 2014

asp.net web api - WinRT use HttpClient to call Web API based URL with token -



asp.net web api - WinRT use HttpClient to call Web API based URL with token -

we building winrt app gets info server web api based & gives info in json and/or xml format.

when app user logs in first time using credentials(username,password), response comes server success bit & token, should used in successive url requests.

i using httpclient sending requests

using (httpclient httpclient1 = new httpclient()) { string url = "http://example.com/abc/api/process1/getlatestdata/10962f61-4865-4e7a-a121-3fdd968824b5?employeeid=6"; //the string 10962f61-4865-4e7a-a121-3fdd968824b5 token sent server var response = await httpclient1.getasync(new uri(url)); string content = await response.content.readasstringasync(); }

now response status code 401 "unauthorised". , xml in response "unauthorised user".

is there need alter in appmanifest??

i've checked this, cant utilize httpclient without credentials??

your capabilities enough. don't need net (client) because it's included in net (client & server).

you not have credentials winrt httpclient, in linked post referr system.net.http.httpclienthandler.

maybe can utilize httpbaseprotocolfilter add together credentials?

using (var httpfilter = new httpbaseprotocolfilter()) { using (var httpclient = new httpclient(httpfilter)) { httpfilter.servercredential... } }

i don't know security mechanism, i'm using httpclient , session-key in cookie. think client code looks fine.

asp.net-web-api windows-runtime windows-store-apps winrt-xaml web-api

No comments:

Post a Comment