Multiple WebRequests

Last post 05-05-2005 20:34 by Anonymous. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 04-22-2005 20:00

    Multiple WebRequests

    There is a website that I have to communicate with by sending xml through the URL I request it with.

    Through one XML command, I log into the server. Through the next XML command, I use my newly logged in status to get privilaged information from the server.

    Here is the problem: every new WebRequest creates a new session. Therefore, when I send the next XML command, the server thinks I'm not logged in because I am missing information.

    I need to maintain my session across multiple Webrequests. How do I do this?

    I know my method works because I can send commands through a browser window and get the correct results. But apparently the browser stores some kind of hidden information that I don't have access to.
  • 04-22-2005 20:02 In reply to

    Re: Multiple WebRequests

    If you know a method of doing this without WebRequests, I am open to those suggestions as well.
  • 04-23-2005 5:17 In reply to

    Re: Multiple WebRequests

    It sounds like any one of several issues can be going on. The ones that immediately come to mind relate to cookies, javascript, session state, etc.

    I got around a similar issue by using an HttpWebRequest to the first (Main) page to obtain a state variable which was stored in the URL used to go to the next (Details) page. However, that is not the only way to store session, so more information about your specific issue is needed. Are you familiar with HttpWebRequest and HttpWebResponse?

    Sanford ("Sandy") J. Asman
    Attorney at Law
    570 Vinington Court
    Atlanta, GA 30350

    Phone: (770) 391-0215
    Fax: (770) 668-9144
    Email: sandy@asman.com
  • 04-23-2005 8:00 In reply to

    Re: Multiple WebRequests

    Yes the fact of multiple ways to store a session state is becoming a daunting reality to me. I had not tried HttpWebRequest or HttpWebResponse yet; thank you for your response. Unfortunately, it seems HttpWebRequest is one-shot-only as well.

    I wish I had more information about the server I am working with, but I do not have physical access to it. All I know about it is what I can retrieve through web diagnostics.

    I know that it's response contains a cookie prefixed by "JSESSION" and it authenticates with a username/password/domain combination. All communication is through XML placed in the URL sent to the server and a stream of XML returned. I don't think javascript is involved in the process.

    I tried setting the credentials of the second WebRequest object according to a new credential based on username/password/domain and it was unsuccessful.

    What I may ask from you (unless you have a better solution in mind or this request is ridiculous) is if you know of a web site that enumerates the different methods authenticating through .NET.

    Or could you share how you got around your issues?

    Or if something I have said has sparked a better idea?
  • 04-23-2005 10:45 In reply to

    Re: Multiple WebRequests

    The whole issue of not being able to begin and keep a single session throughout the transaction (just as my web browser is doing right now) is exceedingly frustrating to me. Especially since I can find example projects that do so in VC++ and eVC (and with which I have completed the required XML transactions). You would think they would retain this functionality in .NET.

    I'm going to try http://www.indyproject.org and see if any of his classes can provide the kind of session connection that I need.
  • 04-23-2005 13:40 In reply to

    Re: Multiple WebRequests

    No luck yet. Indy can accomplish the transaction using .NET, however getting it to run on .NET CF is problematic. I keep getting a TypeLoadException error.
  • 04-23-2005 14:07 In reply to

    Re: Multiple WebRequests

    Here is my guess: the Indy dll's are not compiled in a form that the device can understand. So continues my endless trek into a problem that is taking way too much of my development time. Off to find yet another class...
  • 04-23-2005 18:07 In reply to

    Re: Multiple WebRequests

    I FIGURED IT OUT!! HOLY $%@$*^%, I FIGURED IT OUT!!!

    After 18+ hours of research and 50+ webpages:

    WebRequest myRequest = WebRequest.Create(url);
    WebResponse myResponse = myRequest.GetResponse();

    WebRequest myRequest2 = WebRequest.Create(url2);
    myRequest2.Headers.Set("Cookie", myResponse.Headers.Get("Set-Cookie"));
    WebResponse myResponse2 = myRequest2.GetResponse();

    Turns out cookies were the only barrier to continuous http session.
  • 05-03-2005 20:00 In reply to

    Re: Multiple WebRequests

    Glad you got it and shared... Just remember, when it comes to cookies... sometimes ya bite the cookie, and sometimes the cookie bites you...

    Sanford ("Sandy") J. Asman
    Attorney at Law
    570 Vinington Court
    Atlanta, GA 30350

    Phone: (770) 391-0215
    Fax: (770) 668-9144
    Email: sandy@asman.com
  • 05-05-2005 20:34 In reply to

    Re: Multiple WebRequests

    lol. Thanks Sandy.
Page 1 of 1 (10 items)