ASP.net and thread safety

G

Guest

hello, can anyone please tell me if the following structure is thread safe

visit.cs
class Visit : System.Web.UI.Page
{
//Variables
IVisitProtocol m_oVisitProtocol
public void Configure(IVisiteProtocol oVisiteProtocol)
{
this.m_oVisitProtocol = oVisitProtocol;
if (!this.GeneralControl(out Message))
this.m_oVisitProtocol.DisplayMessage(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(EventArgs 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, IVisiteProtocole
{
//variables
//Public and Private Methods
override protected void OnInit(EventArgs e)
{
base.configure(this);
InitializeComponent();
base.OnInit(e);
}
//creating other classes instances
//like Product oProduct = new Product(); etc..

}

Thanks.
 
G

Guest

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
 
G

Guest

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.Page 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
 
G

Guest

Peter,
This sounds more intersting
would please submit any simple (if you have it of corse) of how to intercept
the appropriate methods in the ASPX page form HttpModule?

Thanks much Peter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top