WebClient Class / Upload File / IIS 405 Error

Discussion in 'ASP .Net' started by Grant Harmeyer, Sep 7, 2004.

  1. 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/d...lrfsystemnetwebclientclassuploadfiletopic.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
    Grant Harmeyer, Sep 7, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message news:<#>...
    > 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/d...lrfsystemnetwebclientclassuploadfiletopic.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
    Sayed Hashimi, Sep 7, 2004
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:<#>...
    >> 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/d...lrfsystemnetwebclientclassuploadfiletopic.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
    Grant Harmeyer, Sep 7, 2004
    #3
  4. Grant Harmeyer

    Joerg Jooss Guest

    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
    Joerg Jooss, Sep 8, 2004
    #4
  5. 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" <> wrote in message news:<uGXU$>...
    > 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" <> wrote in message
    > news:...
    > > 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" <> wrote in message
    > > news:<#>...
    > >> 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/d...lrfsystemnetwebclientclassuploadfiletopic.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
    Sayed Hashimi, Sep 8, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kenneth Myhra

    HTTP error 405 for 'PUT' verb

    Kenneth Myhra, Feb 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,065
    bruce barker
    Feb 17, 2004
  2. Phillip N Rounds

    File Upload issues with WebClient.UploadFile

    Phillip N Rounds, Feb 2, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    11,319
    Bruce Barker
    Feb 2, 2006
  3. Matthew Zimmer

    Servlet error 405

    Matthew Zimmer, Nov 20, 2003, in forum: Java
    Replies:
    3
    Views:
    6,382
    Matthew Zimmer
    Nov 21, 2003
  4. Jeff Thies

    405 error

    Jeff Thies, Jun 29, 2004, in forum: HTML
    Replies:
    1
    Views:
    694
    David Christopher Weichert
    Jun 29, 2004
  5. WebService and IIS wildcard mapping = 405

    , Aug 7, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    135
Loading...

Share This Page