I have defined a SiteConfigs Table/Model/Service class/admin page to define and store application-wide information like site title,keywords,footer text, redirectToWww,pagingSize and ... . now I wonder how should I expose these to my classes ? create a singleton
/ static class to feed all requests of all users or instantiate it where ever needed or ... ?
what is a better way to go through for a asp.net MVC web application ?
what is a better way to go through for a asp.net MVC web application ?
What I understood is setting like title, keywords, footer, etc are site specific and not page/view specific. If it is so, you can put respective markup in layout/master view and you can create base controller class by deriving System.Web.Mvc.Controller class
and put logic to read those common setting in base controller.
m_royasaz
create a singleton / static class to feed all requests of all users or instantiate it where ever needed or ... ?
redirectToWww: I would suggest to take care this at IIS level rather than through code level as it has certain performance advantages for e.g. IIS redirect it before passing request to ASP.NET engine... so it redirect far early even before
request start processing by ASP.NET
What I understood is setting like title, keywords, footer, etc are site specific and not page/view specific. If it is so, you can put respective markup in layout/master view and you can create base controller class by deriving System.Web.Mvc.Controller class
and put logic to read those common setting in base controller.
yes , they are . you mentioned a good point . I'll apply that
well , as your link , singleton is prefered to static , but what about between singleton and a normal instantiation ?
I would suggest to use singleton over normal object as singleton instantiation happen only once except object referenced is set to null. So it has performance advantages.
m_royasaz
yes , they are . you mentioned a good point . I'll apply that
m_royasaz
and , you are right about redirectToWWW , I'm going to remove it .
m_royasaz
Member
39 Points
14 Posts
how to expose these information to the project
Nov 21, 2012 06:30 PM|LINK
I have defined a SiteConfigs Table/Model/Service class/admin page to define and store application-wide information like site title,keywords,footer text, redirectToWww,pagingSize and ... . now I wonder how should I expose these to my classes ? create a singleton / static class to feed all requests of all users or instantiate it where ever needed or ... ?
what is a better way to go through for a asp.net MVC web application ?
thank you in advance
Nandip Makwa...
Participant
1283 Points
296 Posts
Re: how to expose these information to the project
Nov 22, 2012 03:49 AM|LINK
What I understood is setting like title, keywords, footer, etc are site specific and not page/view specific. If it is so, you can put respective markup in layout/master view and you can create base controller class by deriving System.Web.Mvc.Controller class and put logic to read those common setting in base controller.
I think this would be helpful to you http://stackoverflow.com/questions/519520/difference-between-static-class-and-singleton-pattern
redirectToWww: I would suggest to take care this at IIS level rather than through code level as it has certain performance advantages for e.g. IIS redirect it before passing request to ASP.NET engine... so it redirect far early even before request start processing by ASP.NET
You can check my post here http://www.dotnetexpertguide.com/2011/08/iis-7-redirect-domaincom-to.html
Software Engineer by Profession, Learner by Passion!
m_royasaz
Member
39 Points
14 Posts
Re: how to expose these information to the project
Nov 22, 2012 04:25 AM|LINK
1-
yes , they are . you mentioned a good point . I'll apply that
well , as your link , singleton is prefered to static , but what about between singleton and a normal instantiation ?
and , you are right about redirectToWWW , I'm going to remove it .
Nandip Makwa...
Participant
1283 Points
296 Posts
Re: how to expose these information to the project
Nov 22, 2012 05:38 AM|LINK
I would suggest to use singleton over normal object as singleton instantiation happen only once except object referenced is set to null. So it has performance advantages.
Glad to know that my reply answered your query
Software Engineer by Profession, Learner by Passion!