0

I am creating a project using ASP.NET MVC 3. So now I need to pass some data that need to be available into the entire project.

I am using IHttpModule and set values in the HttpContext items. My doubt is, the values I add into HttpContext items will be exclusive values for each user session or will be the same?

public class BaseHttpModule : IHttpModule
{
    context.BeginRequest += context_BeginRequest;

    private void context_BeginRequest(object sender, EventArgs e)
    {
        var application = (HttpApplication)sender;
        var context = application.Context;
        context.Items[Key] = "value1";          
    }

}
Pencho Ilchev
  • 3,201
  • 18
  • 21
Michel Andrade
  • 4,056
  • 5
  • 27
  • 28

2 Answers2

1

Thos items only persist a single request, so therefore they are scoped and exclusive to a particular user insofar as a single user is making that request.

You might want to try something like this

var application = (HttpApplication)sender; 
application.Application["domain"] = "blah"; 
Rob Allen
  • 2,871
  • 2
  • 30
  • 48
0

Those items only survive that single page request. The Context serves a single request.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123