S
Steve Franks
Is there a way I can extend the HttpContext or one of its subclasses to
include a property that exposes a custom class of mine to all ASP.NET pages?
More specifically, I'd like to use a HttpModule to initialize an instance of
a custom class, and have this class exposed directly through the HttpRequest
for the current user through a property I add to the HttpRequest object.
For example, I'd like my developers to be able to use this special class
just like it was a built-in part of the ASP.NET framework, like so:
MyBuiltInClass myclass = HttpContext.Current.Request.BuiltInClass
where, BuiltInClass is a property that holds an instance of MyBuiltInClass
Is there any way to do this?
To clarify, there is a Browser property on the HttpRequest class that
automatically provides an instance of the HttpBrowserCapabilities class. So
from any ASP.NET page you can just do HttpContext.Current.Request.Browser to
get a copy of this class. Well, I would like to create the same type of
system where "behind the scenes" I create a MyBuiltInClass instance for each
HttpContext and then exposre it to all pages through the Request object?
Can this be done using ASP.NET 2.0? Obviously this is done currently as
part of the built-in framework (as in the case of the Browser property I
mentioned above), but I'm not sure if the framework is extensible enough for
me to accomplish this for a custom class. If not, is there some other way
that is just as effective for me to accomplish the same thing? Any ideas?
Thank you in advance.
Steve
include a property that exposes a custom class of mine to all ASP.NET pages?
More specifically, I'd like to use a HttpModule to initialize an instance of
a custom class, and have this class exposed directly through the HttpRequest
for the current user through a property I add to the HttpRequest object.
For example, I'd like my developers to be able to use this special class
just like it was a built-in part of the ASP.NET framework, like so:
MyBuiltInClass myclass = HttpContext.Current.Request.BuiltInClass
where, BuiltInClass is a property that holds an instance of MyBuiltInClass
Is there any way to do this?
To clarify, there is a Browser property on the HttpRequest class that
automatically provides an instance of the HttpBrowserCapabilities class. So
from any ASP.NET page you can just do HttpContext.Current.Request.Browser to
get a copy of this class. Well, I would like to create the same type of
system where "behind the scenes" I create a MyBuiltInClass instance for each
HttpContext and then exposre it to all pages through the Request object?
Can this be done using ASP.NET 2.0? Obviously this is done currently as
part of the built-in framework (as in the case of the Browser property I
mentioned above), but I'm not sure if the framework is extensible enough for
me to accomplish this for a custom class. If not, is there some other way
that is just as effective for me to accomplish the same thing? Any ideas?
Thank you in advance.
Steve