Help please - HTTPWebRequest - using the same request object but different URI? RRS feed

  • Question

  • User609686767 posted


    In my first web request, I'm posting to a URL login site, then when the login is successful I need to use that same request object (maybe because it has the security key already when login was successful) to post data.

    I tried changing the proxy of the request object, but it won't let me, exception is thrown because it says I can no longer change it since it has been submitted already.

    Dim myNewURLValue As String = "https://contoso.com"

     Dim newUri As Uri = New Uri(myNewURLValue)

    If (request IsNot Nothing) Then

    request.KeepAlive = True
    myProxy = DirectCast(request.Proxy, WebProxy)
    myProxy.Address = newUri

    request.Proxy = myProxy


    EXCEPTION: This operation cannot be performed after the request has been submitted.

    Any ideas?

    Thank you very much.

    Thursday, March 26, 2015 5:13 PM


  • User1644755831 posted

    Hello janilane,

    The "This operation cannot be performed after the request has been submitted." exception occurs because when you ask for response from the server it means your request has already been submitted and you can not use that request again. if you want to post data again than you need to create new web request. you should research that after login in to URL site is it returning any token or id that can be used to identify the use. it all depends on how the functionality on the URL site has been implemented. There must be some mechanism on url site to identity the request are coming from which user.  I suggest you should research on that.

    Hope this helps.

    With Regards,

    Krunal Parekh 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 27, 2015 5:17 AM