Question

I'm working on an ASP.NET 4.0 Web Forms project, after a break of about 5 years, and I'm confused about the submit behaviour.

In the click event of a button, I sleep the thread so that I can click the submit button multiple times.

From what I can tell, ASP.NET is preventing the click event being called more than once. Is this true?

BTW: I've turned off javascript for this test.

Was it helpful?

Solution

"ASP.NET is preventing the click event being called more than once. Is this true?"

No, actually what is happening to you is that your events are blocked by the lock of the session. (What session is on asp.net, is a module on asp.net that can keeps data for each user that visit the site)

So when you make a submit, and the page is running this submit, and then you make a second one before the first one replay, actually the second one is waiting the first to finish and unlock the session.

To make a test and prove that the session is locking your request, turn off the session and try again your test.

relative:
Web app blocked while processing another web app on sharing same session
What perfmon counters are useful for identifying ASP.NET bottlenecks?
Replacing ASP.Net's session entirely
Trying to make Web Method Asynchronous

OTHER TIPS

No, As you are making your main thread sleep it causes the session to get blocked which prevents it from processing any further requests. Hence it gives that effect. If you have an independent task which can be done without web request and response, then you can perform it in separate thread. This will not block your process.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top