Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Problem in uploading file with HttpWebRequest

Problem in uploading file with HttpWebRequest

Scheduled Pinned Locked Moved C#
helpcsharphtmlasp-netdatabase
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chintan Desai
    wrote on last edited by
    #1

    Hi all, I am getting problem in uploading file with ASP.NET (C#). I have set almost all property of HttpWebRequest instance. I have too set properties in my Virtual directory. I am getting error as "Cannot connect to the configuration database". I dont know what is configuration database in these case. My application takes 10 second when it execute the below code: HttpWebResponse httpResponse =httpWebResponse)httpRequest.GetResponse(); I have used Stream to write uploaded file content. It seems to be working fine. Even I am getting my Stream object by GetRequestStream(). ======================================================================== here is my code. string URI = "http://" + txtServerIP.Text + "/" + "VDir" + "/" + fUpload.FileName; HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(new Uri(URI)); FileInfo fileInfo = new FileInfo(fUpload.PostedFile.FileName); httpRequest.Method = WebRequestMethods.Http.Put; httpRequest.AllowWriteStreamBuffering = true; httpRequest.Credentials = new NetworkCredential(txtUserName.Text, txtPassword.Text); httpRequest.ContentLength = fileInfo.Length; httpRequest.ContentType ="text/html"; FileStream fs = new FileStream(fUpload.PostedFile.FileName,FileMode.Open); Stream stream = httpRequest.GetRequestStream(); contentLength = fs.Read(buff, 0, buffLen); while (contentLength != 0) { stream.Write(buff, 0, contentLength); contentLength = fs.Read(buff, 0, buffLen); } stream.Close(); fs.Close(); //Here it takes 10 seconds.:mad: HttpWebResponse response = (HttpWebResponse)httpRequest.GetResponse(); Could you pls help me. Thanks,

    Regards Chintan HCL Technologies...India (Carefully) listen->(Deeply)Think->(Clearly)Understand->(Patiently) reply...

    M 1 Reply Last reply
    0
    • C Chintan Desai

      Hi all, I am getting problem in uploading file with ASP.NET (C#). I have set almost all property of HttpWebRequest instance. I have too set properties in my Virtual directory. I am getting error as "Cannot connect to the configuration database". I dont know what is configuration database in these case. My application takes 10 second when it execute the below code: HttpWebResponse httpResponse =httpWebResponse)httpRequest.GetResponse(); I have used Stream to write uploaded file content. It seems to be working fine. Even I am getting my Stream object by GetRequestStream(). ======================================================================== here is my code. string URI = "http://" + txtServerIP.Text + "/" + "VDir" + "/" + fUpload.FileName; HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(new Uri(URI)); FileInfo fileInfo = new FileInfo(fUpload.PostedFile.FileName); httpRequest.Method = WebRequestMethods.Http.Put; httpRequest.AllowWriteStreamBuffering = true; httpRequest.Credentials = new NetworkCredential(txtUserName.Text, txtPassword.Text); httpRequest.ContentLength = fileInfo.Length; httpRequest.ContentType ="text/html"; FileStream fs = new FileStream(fUpload.PostedFile.FileName,FileMode.Open); Stream stream = httpRequest.GetRequestStream(); contentLength = fs.Read(buff, 0, buffLen); while (contentLength != 0) { stream.Write(buff, 0, contentLength); contentLength = fs.Read(buff, 0, buffLen); } stream.Close(); fs.Close(); //Here it takes 10 seconds.:mad: HttpWebResponse response = (HttpWebResponse)httpRequest.GetResponse(); Could you pls help me. Thanks,

      Regards Chintan HCL Technologies...India (Carefully) listen->(Deeply)Think->(Clearly)Understand->(Patiently) reply...

      M Offline
      M Offline
      Mark J Miller
      wrote on last edited by
      #2

      I doubt the problem is with your code. The error returned is from the server and is probably because your server has SharePoint installed. Search google for the error message and there are a ton of results which talk about this specific error. http://www.google.com/search?hl=en&rls=com.microsoft%3Aen-US&q=Cannot+connect+to+the+configuration+database[^] If none of these seem to help solve your problem then you'll need to post some more information about the configuration of the server you are trying to communicate with.

      Mark's blog: developMENTALmadness.blogspot.com

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups