|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ASP.net and thread safetyvisit.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. 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 -- Show quoteHide quoteCo-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.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. 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 Show quoteHide quote "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.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. SEB,
For something like this, I would consider creating an HttpModule and plugging this into your web.config. Then your checks could be done automatically by interceptiing the appropriate methods in the ASPX page lifecycle. Peter -- Show quoteHide quoteCo-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com "SEB" wrote: > 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 > > > > > > > > > > > "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.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. 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. Show quoteHide quote "Peter Bromberg [C# MVP]" wrote: > SEB, > For something like this, I would consider creating an HttpModule and > plugging this into your web.config. Then your checks could be done > automatically by interceptiing the appropriate methods in the ASPX page > lifecycle. > Peter > > -- > Co-founder, Eggheadcafe.com developer portal: > http://www.eggheadcafe.com > UnBlog: > http://petesbloggerama.blogspot.com > > > > > "SEB" wrote: > > > 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 > > > > > > > > > > > > > > > > > > > > > > "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.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.
Other interesting topics
global functions?
MSWord Common functionality across pages, what's the best solution? Asp.net 2.0 caching and images DataGrid, Edit and the Enter Key Dot Net or Javascript problem??? ASP.NET Embedded Resources Very Strange Problem! (Derived Controls) - Help! Architectural assistance needed! Help on LinkButton vs PushButton ?? |
|||||||||||||||||||||||