thank you Peter for taking time to respond.
I am going to start with your second part. I belive it confirm that evry
code is thread safe as long as there is no static fields / members
even it's not "a good logic" or there is a btter way to do it.
Is that rtight Peter?
about the first part. I did post an other question here but (with all my
respect to evry one) no one gave an answer.
here is my question again Peter and hope you will give an answer or any
redirection of who to do what i am looking for
let's says we have over 100 apsx pages
on each page there have to be checks (no matter if they are simple or
complexe)
exmple of these checks is to validate the Remote IP and check if HTTPS is ON
what is the best way, creating/using a control (no matter server / user /
custome) then each time you have to go throught each page to add/remove a
propertise in case your customer came up with a strange ideas or make the
Visite class that derive from System.Web.UI.P age then let Visit make all the
checks and any changes to the initial checks will be only to Visit class then
make every aspx class derive from Visit and every page.
all i nee to do after that is recompile the project and done with it
i must says that i am using Visit class for more things in other projects
because it really worked with me the first time but i will appreciate your
help if you can redirect me to the right way
"Peter Bromberg [C# MVP]" wrote:
Simo,
I question the validity / logic of deriving class Visit from the Page Class.
There is no reason why each Page instance can't make a method call on a
separate class, or even use a Server Control that does this type of thing.
Each page instance and every object instance that it runs is "thread safe"
to the extent that the fields / members aren't static, because each runs on
an individual and separate thread.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Simo" wrote:
hello, can anyone please tell me if the following structure is thread safe
visit.cs
class Visit : System.Web.UI.P age
{
//Variables
IVisitProtocol m_oVisitProtoco l
public void Configure(IVisi teProtocol oVisiteProtocol )
{
this.m_oVisitPr otocol = oVisitProtocol;
if (!this.GeneralC ontrol(out Message))
this.m_oVisitPr otocol.DisplayM essage(Message) ;
}
private bool GeneralControl( out string Message)
{
//checks that need to be done on evry request
Message = checks_value/string.empty;
return true/false;
}
protected override void OnInit(EventArg s e)
{
base.OnInit(e);
//more code dealing with the site skeleton
}
//more Public and Private Methodes
}
product.aspx.cs
//this the code behind of product.aspx and almost evry page has the same
structure
public class product : Visit, IVisiteProtocol e
{
//variables
//Public and Private Methods
override protected void OnInit(EventArg s e)
{
base.configure( this);
InitializeCompo nent();
base.OnInit(e);
}
//creating other classes instances
//like Product oProduct = new Product(); etc..
}
Thanks.