Does each request in ASP.NET MVC, share static variables with other requests?
asp.net-mvc
Solution
Yes, static variables are shared across the entire application (over all threads). You cannot safely access these variables without synchronization from various requests (since each request is handled on a different thread).
Even if you synchronize access to these variables, there's only a single instance of the static variable so all threads will see the same value - you can't have request-specific values this way.
Problem
Can I store my active Entity framework Database Context for the request, as a static property somewhere, so it's easily fetchable from Validators, helpers etc. **E.G set it from a global action filter onto a static class as ``` public static DBContext GlobalHelper.ActiveDbContextForRequest; ``` Does each request share these static properties though? If they do I suppose it cannot work.