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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Failed to createa a new WinHttpRequest

Failed to createa a new WinHttpRequest

Scheduled Pinned Locked Moved ASP.NET
helpcsharpquestionasp-net
1 Posts 1 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.
  • D Offline
    D Offline
    DKScherpy
    wrote on last edited by
    #1

    I'm stuck and hoping someone else can help. I'm working on an ASP.NET app (C#). At one point, I need to create an WinHttpRequest object that uploads a file. Here is the code: try { WinHttpRequest whr = new WinHttpRequest(); whr.SetTimeouts( 0, 0, SendTimeout, ConnectTimeout ); whr.Open( "POST", (( this.IsProduction ) ? LIVE_URL : DEV_URL), false ); whr.SetRequestHeader( "ENCTYPE", "multipart/form-data" ); whr.SetRequestHeader( "Name", "FileUpload); whr.Send( this.UploadFile.ToString() ); // create the content request whr.WaitForResponse( ResponseTimeout ); ResponseText = whr.ResponseText; this.UploadFile.Uploaded = ( ResponseText != null && ResponseText.ToUpper().IndexOf( "SUCCESS" ) != -1 ) ? true : false; } catch ( Exception ex ) { ResponseText = ex.Message; } // try/catch But for some reason the code just halts and doesn't come back after the line: WinHttpRequest whr = new WinHttpRequest(); I've put code in before and after the line to log what is happening and the code up to that point works fine, and then it goes into the new WinHttpRequest and then nothing. Oh, and it works _some_ of the time in this app and works consistently when the same code is used in other apps. I am making a lot of new WinHttpRequest objects throughout the code, could that be a problem? Any ideas or leads would be very helpful. Thanks in advance.

    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