silverlight - Missing credential from request in OOB application -


i'm writing simple silverlight application in have following code, think pretty standard:

webrequest.registerprefix("http://", webrequestcreator.clienthttp); var request = new webclient();  var cred = new networkcredential(server.username, server.password); request.credentials = cred; request.usedefaultcredentials = false;  request.downloadstringcompleted += testservercompleted; var uri = new uri(server.getrequesturl(methods.ping)); request.downloadstringasync(uri); 

yet when view request in fiddler, no credentials added headers. missing? shouldn't there "authorization: basic ..." header in there?

try this.

        httpwebrequest.registerprefix("http://", webrequestcreator.clienthttp);         httpwebrequest req = (httpwebrequest)httpwebrequest.create(url);         req.usedefaultcredentials = false;         req.credentials = ew networkcredential(server.username, server.passwor          req.contenttype = "text/xml;charset=\"utf-8\"";         req.accept = "text/xml";         req.method = "post";         return req;          req.begingetresponse((iasyncresult asynchronousresultresponse) =>             {                 try                 {                     httpwebrequest requestresponse = (httpwebrequest)asynchronousresultresponse.asyncstate;                     httpwebresponse response = (httpwebresponse)requestresponse.endgetresponse(asynchronousresultresponse);                     stream streamresponse = response.getresponsestream();                     streamreader streamread = new streamreader(streamresponse);                     string responsestring = streamread.readtoend();                      //your response here in responsestring                      streamresponse.close();                     streamread.close();                     response.close();                 }                 catch (exception e)                 {                     callback(null, e);                 }             }, webrequest); 

i hope can help, 2 months later...


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -