servicepointmanager and multiple threads concern

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a aspx web application running on IIS that makes requests (http posts,
soap etc.) to other web servers in order to service a post/get. In some cases
these requests require that I set static properties of the
ServicePointManager (e.g. the CertificatePolicy).

I am concerned about thread safety, namely that changes made by one thread
to ServicePointManager properties will impact on web requests made by other
threads.

e.g.
-Two people post to joe.aspx.
-As a result threads a and b are started.
-In thread a, an https request must be made to www.some fictitious site.com.
-In thread b, an https request must be made to www.some other site.com and
requests of that site require a different
ServicePointManager.CertificatePolicy.
-While the request for thread a is being handled, thread b comes along and
overrides the Certificate policy.
-Result -> incorrect policy applied to thread a's request.

I am pretty sure this is possible in a normal application that has multiple
threads making httpwebrequests. I am under the assumption that simultaneous
requests of my aspx pages will result in multiple threads being run in my
application and that I should therefore be concerned about it in my web
applications as well (is this rougly correct? is it depedent on IIS settings?)

Is this a valid concern?

Given that it is, I have thought of ways to synchronize the requests with
varying trade-offs between performance and complexity. But, I would be
interested in any elegant solution that synchronizes the requests and doesn't
drastically impact on performance.

Any other solutions?


Also, given that this is a problem, shouldn't the certificatepolicy (and
other properties that impact on the handling of httpwebrequests) be
implemented in some other way so as not to so subtly be a thread safety
concern?


Thanks
 
Back
Top