c# - getasync exception in silverlight -


hi guys trying send getasync request silverlight 5. post async working without problem getasync throw exception when adding authorization header. when not adding authorization header without exception 401. should fix it?

the code:

    client.defaultrequestheaders.add("authorization", "bearer secrettoken");  var getasynctask = await client.getasync("http://api.enteroption.com/api/userdetails/getuseridbytoken/"); 

the exception:

system.argumentexception occurred   message=""   stacktrace:        @ microsoft.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)        @ microsoft.runtime.compilerservices.taskawaiter.handlenonsuccess(task task)        @ microsoft.runtime.compilerservices.taskawaiter.validateend(task task)        @ microsoft.runtime.compilerservices.taskawaiter`1.getresult()        @ consoleapplication3.class1.<func>d__1.movenext()   innerexception: system.argumentexception        message=value not fall within expected range.        stacktrace:             @ system.net.browser.browserhttpwebrequest.internalendgetresponse(iasyncresult asyncresult)             @ system.net.browser.browserhttpwebrequest.<>c__displayclassa.<endgetresponse>b__9(object sendstate)             @ system.net.browser.asynchelper.<>c__displayclass4.<beginonui>b__0(object sendstate)        innerexception: 

i know late struggled quite while getting head wrapped wrong way round .. did following , worked, annoys me problem

  client.defaultrequestheaders.add("authorization", "bearer " + kvp.value);   //client.defaultrequestheaders.authorization = new authenticationheadervalue("bearer", kvp.value ); 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -

r - Update two sets of radiobuttons reactively - shiny -