Passing security credentials to ASP from .net

From: Raj (anonymous_at_discussions.microsoft.com)
Date: 02/23/04


Date: Sun, 22 Feb 2004 16:36:06 -0800

Hi All,
Here's my situation. I have a ASP page which requires windows authentication. The page works fine when I access it from IE and I am able to login succesfully.
Now I am writing some .NET code to access the page. I pass in some data for the form. I always get a 401 error. I am looking for some pointers/sample code that tells me how I can pass windows login credentials to my ASP page. I did try NetworkCredentials but that fails. Below Is my code.

WebClient wc = new WebClient();
NameValueCollection nvc = new NameValueCollection();
nvc.Add("cmdSubmit","send");
nvc.Add("txtMsgText","Test Message");

byte[] buffer;
buffer = wc.UploadValues(uri,"POST",nvc);
string streamReader;
streamReader = System.Text.Encoding.Default.GetString(buffer);

Help will be appreciated

Thanks

Raj



Relevant Pages

  • Re: Passing security credentials to ASP from .net
    ... pointers/sample code that tells me how I can pass windows login credentials ... > NameValueCollection nvc = new NameValueCollection; ... > buffer = wc.UploadValues; ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: WebClient Timeout Exception
    ... > I have a problem with the WebClient and uploading a file to a web server. ... > Buffer length is around 4 MB. ... > Writing a 2k chunk and calling flush until the entire buffer is read ... > Writing a webservice method that takes an array of bytes> ...
    (microsoft.public.dotnet.languages.csharp)
  • WebClient Timeout Exception
    ... I have a problem with the WebClient and uploading a file to a web server. ... Buffer length is around 4 MB. ... Writing a 2k chunk and calling flush until the entire buffer is read ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Is there a clean way to create a byte[] from an HttpWebRequest.Read?
    ... buf.CopyToor Buffer.BlockCopy) is inneficient. ... loop, using a smaller buffer) from the response and writing to a ... you could instead use WebClient: ...
    (microsoft.public.dotnet.languages.csharp)