/    Sign up×
Community /Pin to ProfileBookmark

C# web request

Hi all
I am trying to write application that connects to some website and register to some course in my college.
Before I register i should add the course number to “my basket”.
So I created 2 HttpWebrequests.
The first one adds the course to the basket and the second one should register

First request works properly.
(I can see that the course successfully added to the basket)
But when I send the second request, it does not work

It seems like the second request does not remember course added to basket.
It returns “the basket is empty” response.

I have no idea…

Thank you

to post a comment
Full-stack Developer

7 Comments(s)

Copy linkTweet thisAlerts:
@1DayTutoringJun 04.2012 — Maybe a cookie has not been saved properly after the first request or a different session has been initiated at the second ajax request.
Copy linkTweet thisAlerts:
@matveyauthorJun 05.2012 — I am saving cookies properly

How can i can two requests in one session ?

Thank you
Copy linkTweet thisAlerts:
@holyhttpJun 05.2012 — What's the average amount of time between the 2 requests?
Copy linkTweet thisAlerts:
@matveyauthorJun 05.2012 — The second request goes immediately after the first
Copy linkTweet thisAlerts:
@holyhttpJun 06.2012 — Try to space out the 2 requests about 2 to 5 seconds to see what happens.
Copy linkTweet thisAlerts:
@matveyauthorJun 06.2012 — When the session is closed the basket is resets.

Does it relate to space between 2 requests ?

How can I determine the space ?
Copy linkTweet thisAlerts:
@holyhttpJun 06.2012 — Generally remembering the current user is done through a cookie, a session variable, passing query variables or through hidden form fields.

I found that when cookies are involved, it generally a good idea to wait for a few seconds (2-5) when the cookie is first set before making a subsequent HTTP request where that cookie value is needed.

However once a cookie is saved in your machine, it does not really matter how much interval of time there is between subsequent requests.

First you need to check whether under normal circumstances (regular user initiated HTTP requests) the registration process proceeds normally or not.

From there you can set a sufficient delay (1 minute) between the 2 requests of your scripts. If that works then you can go ahead and reduce that interval further and further to see if there is a cutting point.

It will also help you to see if the web site passes along some hidden form fields between pages. That sometimes is a trick to prevent automated programs from making submissions.

Again I can only speculate. Without seeing your code and the web site it's next to impossible to pinpoint the source of your technical problem.
×

Success!

Help @matvey spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...