HttpWebRequest and IIS

G

Guest

This is gettin' me crazy!

I need to get and send data for the server, but i dont want to use anonymous
authentication.
It works fine with anonymous authentication, but when i try to use log and
pass... it crashes, or simply doesnt work.
Maybe it has something to do with IIS...but i dont know.
Ill post the code im using.

NetworkCredential NC= new NetworkCredential("Log","Pass");
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(downloadUrl);

req.Credentials=NC;
req.Method = "GET";

HttpWebResponse resp = (HttpWebResponse) req.GetResponse();

// Retrieve response stream
Stream respStream = resp.GetResponseStream();
 
G

Guest

Ok, think i worked out the problem.

First i defined IIS authentication as Basic
Then created a new user
Defined security for the folders i wanted to use

And last but not least, a new piece of code:

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uploadUrl);
req.Credentials= new NetworkCredential(maq.Trim()+ "\\LOG","PASS");
req.Method = "PUT";
req.AllowWriteStreamBuffering = true;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top