Error 403 - Forbidden

G

Guest

Im trying to send a file (.zip) to a iis server, but i always get an error.
I searched everywhere but didnt find any help.
Maybe u guys and gals could help me.
I will be trully apreciated.

Here it is the code:


public void UploadFileBinary(string localFile, string uploadUrl)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uploadUrl);

req.Method = "PUT";
req.AllowWriteStreamBuffering = true;

// Retrieve request stream
Stream reqStream = req.GetRequestStream();
StreamWriter wrtr = new StreamWriter(reqStream);

// Open the local file
FileStream rdr = new FileStream(localFile, FileMode.Open);

// Allocate byte buffer to hold file contents
byte[] inData = new byte[4096];

// loop through the local file reading each data block
// and writing to the request stream buffer
int bytesRead = rdr.Read(inData, 0, inData.Length);
while (bytesRead > 0)
{
reqStream.Write(inData, 0, bytesRead);
bytesRead = rdr.Read(inData, 0, inData.Length);
}

rdr.Close();
wrtr.Close();
reqStream.Close();

req.GetResponse();
}
 
R

Richard Thombs

Marco said:
Im trying to send a file (.zip) to a iis server, but i always get an error.
I searched everywhere but didnt find any help.
Maybe u guys and gals could help me.
I will be trully apreciated.

Sorry for the stupid obvious question, but is the folder you are writing
to write to actually writable by the Windows user that your web site is
running as?

R.
 
G

Guest

Its working!
i know its stupid, but i have to give administrator role to the user on the iis, or else it wont work.
but then...where is the security of that?
if i want to access thru gprs wont it be a risk?

thx guys!
 
C

Chris Tacke, eMVP

That's a gigantic security hole! You simply need to give the IIS user
(IWAM_USER blah, blah or something like that) write permission for the
target directory.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
---
Principal Partner
OpenNETCF Consulting
www.OpenNETCF.com
 

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

Similar Threads


Top