ok, maybe some more information.
This is an existing application.
It is a web based catalog editor for an etailer.
When it was written, there were perhaps 5 employees in the company. Over a
hundred now.
There were perhaps 2 people who initially entered data into the catalog.
I'm not sure how many there are now, must over 10 people. There are about to
be another 10 from a data entry company.
There was no authorization. There is now as I just finished that portion.
There is no auditing, that is what I'm working on now.
I've decided to binary serialize any business objects to store them in SQL
image fields, got that working ( at least until those objects change, but
I'll worry about that later. Most of the time, the auditing needs will be "
what happened in the last two days" )
Now, security is done through a "BasePage" that checks whether a person can
see the current page.
All pages inherit from BasePage.
All pages instantiate a DAL object, and call methods to do any SQL access.
I need to audit any Insert, Delete, Change actions.
Part of the audit is Who did the change, which the BasePage has a property
for.
( Using integrated auth )
Thus, I need access to the Calling/Instantiating object, not for the Page
context, but for what the page object contains.
If I really MUST change all the calls, well, I'll figure out some non-tying
way to do it, but I didn't want to find and change them all because this
WOULD tie my DAL to the pages.
There is no way to do this in 1.1?
Cripes, I hope they put it in for 2.0 I'll have to go look.
Eliyahu Goldin said:
Well, you can almost always tell if you are in a web application by checking
HttpContext.Current on null.
I am not going to disagree with you on your points. I just think we should
sometimes give directions how to achieve a goal in a certain way even if we
would not have taken this way ourselves.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
Robbe Morris said:
Yes, could definitely do this but it would be bad design
practice to incorporate the HttpContext in a data access layer
class. What happens when you need to deploy that data access
layer in a non-web environment?
The bigger question for me is what value is there to telling
the data access layer which class instantiated it or in what
environment it was called from. Typically, you'd write
separate methods to perform this sort of logging
as an http handler or via some other method triggered
from the user interface.
--
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/adonet_source_code_generator.asp
Eliyahu Goldin said:
You can pass the reference to the page in a session variable and access
it from a class as HttpContext.Current.Session["myPage"].
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
There is no way to get it?
I can change the New to get the information, but I didn't really want to
have to change all the pages that instantiate the class.
:
You don't. You'd have to pass that in as a parameter
in the constructor (or some method in the class).
--
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/adonet_source_code_generator.asp
Not sure if I'm posting this in the right spot, but....
Lets say i have a class for data access that gets instantiated on
each
page
in a web application ( .Net 1.1 )
From inside that class, how can I get a reference to the page that
instantiated it?
I'm assuming there is something in system.reflection, but I'm not
familiar
with reflection enough to figure out what to use.