Custom Attributes and Cookies
-
I have created a custom attribute which accepts a boolean value. The attribute will be added to the ASPX class declaration, and depending on the value of that attribute I want to create/modify a cookie.
[MyAttribute(true)] Public Class TestPage : System.Web.UI.Page { ... }
The cookie value will determine what actions I take in an HttpModule that I've created (i.e. if cookie value = true then do steps a, b and c otherwise just do steps a and c). My question is this...Since there isn't a method call anywhere that will trigger the required reflection to check the value of the attribute (which will in turn tell me what value to set the cookie to) is there anyway that I can use an HttpHandler or some other mechanism will set the cookie value? I'm trying to avoid having to add any code to the page other than the Custom Attribute. Am I going about this the wrong way? I've been looking around at some articles and I don't think the HttpHandler will work because it doesn't look like there is any way of accessing the the Custom Attributes from the context object. But of course I could be completely wrong. As usual, any help or links to good articles would be very much appreciated.