Friday, 27 September 2013

WebClient POST fails for ActiveX control in web application

WebClient POST fails for ActiveX control in web application

Hi All i have weird requirement, based on clients request i have developed
activeX control to drag and drop files then upload files to server. I am
using upload ActiveX control in web application which has forms & Windows
athentication. My ActiveX control is Windows User control where i am
trying to POST files using WebClient API. I am assuming that ActiveX's
WebClient API should use credentials of website i logged in to POST files
to server but its not happening when i use
WebClient client = new WebClient();
client.UseDefaultCredentials = true;
//It redirects me to login page.
When i use network credentials? Not sure i whether to use win login or
website login credentils
WebClient client = new WebClient();
client.Credentials = new NetworkCredential("me", "password", "domain");
//Throws me an error
//The remote server returned an error: (401) Unauthorized.
What is the best way to pass authentication/Authorization to ActiveX so
that it can upload easily to server.

No comments:

Post a Comment