473,395 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

WebClient Class / Upload File / IIS 405 Error

When I try to upload a file to a resource on my local webserver, my code
catches an exception that a 405 error (method not supported) has occured on
the server. I set the code up nearly exactly as it is shown in the following
link:

http://msdn.microsoft.com/library/de...dfiletopic.asp

The only thing I did differently is that I also set the BaseAddress property
of the WebClient instance. I have tried using both of the overloaded
UploadFile() methods with the same results each time. Is there any really
good documentation out there on the use of the System.Net.WebClient class?

TIA,

Grant Harmeyer
Nov 18 '05 #1
4 5407
What URL are you posting to? The url has to be a dynamic url. For
example,

You can't post to something like:

http://website.com/uploads/

The url has to be something like:

http://website.com/uploads/doupload.aspx

If you are aware of the above, then how large is the file. Your
machine.config file has a max on the length of uploaded files.

sayed
"Grant Harmeyer" <ne*@internetapollo.com> wrote in message news:<#M**************@TK2MSFTNGP15.phx.gbl>...
When I try to upload a file to a resource on my local webserver, my code
catches an exception that a 405 error (method not supported) has occured on
the server. I set the code up nearly exactly as it is shown in the following
link:

http://msdn.microsoft.com/library/de...dfiletopic.asp

The only thing I did differently is that I also set the BaseAddress property
of the WebClient instance. I have tried using both of the overloaded
UploadFile() methods with the same results each time. Is there any really
good documentation out there on the use of the System.Net.WebClient class?

TIA,

Grant Harmeyer

Nov 18 '05 #2
I was unaware that it needed to be a dynamic URL. That clears it up a bit.
Now, how would I take the array of bytes that is read in and then
re-construct the file on the server?

Thanks again,

Grant Harmeyer

"Sayed Hashimi" <ha***********@hotmail.com> wrote in message
news:3a**************************@posting.google.c om...
What URL are you posting to? The url has to be a dynamic url. For
example,

You can't post to something like:

http://website.com/uploads/

The url has to be something like:

http://website.com/uploads/doupload.aspx

If you are aware of the above, then how large is the file. Your
machine.config file has a max on the length of uploaded files.

sayed
"Grant Harmeyer" <ne*@internetapollo.com> wrote in message
news:<#M**************@TK2MSFTNGP15.phx.gbl>...
When I try to upload a file to a resource on my local webserver, my code
catches an exception that a 405 error (method not supported) has occured
on
the server. I set the code up nearly exactly as it is shown in the
following
link:

http://msdn.microsoft.com/library/de...dfiletopic.asp

The only thing I did differently is that I also set the BaseAddress
property
of the WebClient instance. I have tried using both of the overloaded
UploadFile() methods with the same results each time. Is there any really
good documentation out there on the use of the System.Net.WebClient
class?

TIA,

Grant Harmeyer

Nov 18 '05 #3
Grant Harmeyer wrote:
I was unaware that it needed to be a dynamic URL. That clears it up a
bit. Now, how would I take the array of bytes that is read in and then
re-construct the file on the server?


You *don't* need a web application (dynamic URL???) to process a file
upload, if the client uses HTTP PUT instead of HTTP POST. PUT writes the
file directly to the location designated by the URL, but of course you need
to have the appropriate permissions to do that.

When using ASP.NET, you can process an uploaded (POSTed) file using the
HttpRequest.Files property.

Cheers,

--
Joerg Jooss
jo*********@gmx.net
Nov 18 '05 #4
Grant,

When you use the UploadFile method on the WebClient class, you can
then get to the uploaded file(s) by:

<%@ Import Namespace="System"%>
<%@ Import Namespace="System.IO"%>
<%@ Import Namespace="System.Net"%>
<%@ Import NameSpace="System.Web"%>

<Script language="C#" runat=server>
void Page_Load(object sender, EventArgs e) {

foreach(string f in Request.Files.AllKeys) {
HttpPostedFile file = Request.Files[f];
file.SaveAs("c:\\inetpub\\test\\UploadedFiles\\" +
file.FileName);
}
}

</Script>
<html>
<body>
<p> Upload complete. </p>
</body>
</html>
The Request has a Files collection that you use to get the uploaded
files. This is shown in the link you posted with the original message.
If this isn't what you were asking, please post some of your code so I
can help you further.
sayed

"Grant Harmeyer" <ne*@internetapollo.com> wrote in message news:<uG**************@TK2MSFTNGP15.phx.gbl>...
I was unaware that it needed to be a dynamic URL. That clears it up a bit.
Now, how would I take the array of bytes that is read in and then
re-construct the file on the server?

Thanks again,

Grant Harmeyer

"Sayed Hashimi" <ha***********@hotmail.com> wrote in message
news:3a**************************@posting.google.c om...
What URL are you posting to? The url has to be a dynamic url. For
example,

You can't post to something like:

http://website.com/uploads/

The url has to be something like:

http://website.com/uploads/doupload.aspx

If you are aware of the above, then how large is the file. Your
machine.config file has a max on the length of uploaded files.

sayed
"Grant Harmeyer" <ne*@internetapollo.com> wrote in message
news:<#M**************@TK2MSFTNGP15.phx.gbl>...
When I try to upload a file to a resource on my local webserver, my code
catches an exception that a 405 error (method not supported) has occured
on
the server. I set the code up nearly exactly as it is shown in the
following
link:

http://msdn.microsoft.com/library/de...dfiletopic.asp

The only thing I did differently is that I also set the BaseAddress
property
of the WebClient instance. I have tried using both of the overloaded
UploadFile() methods with the same results each time. Is there any really
good documentation out there on the use of the System.Net.WebClient
class?

TIA,

Grant Harmeyer

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Federico Bari | last post by:
I have the necessity to send an xml file to a CGI application using the https protocol (then the CGI application have to store the datas of the xml file in a mySQL database). I saw the useful...
6
by: genc ymeri | last post by:
Hi, We are struggeling to upload a file through a C# webClient into JBoss web server. Meanwhile we are able to upload a file from the webserver itself. The problem is only with C# webClient . The...
4
by: Shawn Mesiatowsky | last post by:
I have an html form that accepts a file for uploading, but I wanted to create a program to automate the upload procedure. I beileive you use the Webresponse class, but I was not sure how to use...
2
by: Brian | last post by:
Hi, I've been trying to find a way to upload file to another site that is not using IIS. The site that I want to upload file to has a simple php script to receive file uploaded through standard...
3
by: Brian | last post by:
Hi, I've been trying to find a way to upload file to another site that is not using IIS. The site that I want to upload file to has a simple php script to receive file uploaded through standard...
1
by: Pedro Carvalho | last post by:
I am using a WebClient.Upload File method on the Client side and, to accept posted files on the Server side, I am using an ASP.NET page with the following code: void Page_Load(object sender,...
1
by: Greenboy | last post by:
Hello guys! I'm using Visual Basic .Net to build an E-mail management system. So, I have a WebService hosted in a Windows 2000 Server (IIS 5.0) that I use from my client application to upload...
2
by: Deepson Thomas | last post by:
Hi, Iam trying to use WebClient class under system.net namespace to download files from internet via http. For that iam using DownloadFile method. But when ever iam trying to download any file...
4
by: lawrence k | last post by:
I've a file that starts like this: <form id="pdsForm" method="post" action="/mcControlPanel.php" class="mcForm" charset="UTF-8" enctype="multipart/form-data" > and it contains this input: ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.