locked
how to expose these information to the project RRS feed

  • Question

  • User1706054173 posted

    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

    Wednesday, November 21, 2012 2:30 PM

Answers

  • User-576912550 posted

    m_royasaz

    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 .

    Glad to know that my reply answered your query Smile

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 22, 2012 1:38 AM

All replies

  • User-576912550 posted

    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.

    create a singleton / static class to feed all requests of all users or instantiate it where ever needed or ... ?

    I think this would be helpful to you http://stackoverflow.com/questions/519520/difference-between-static-class-and-singleton-pattern

    redirectToWww,pagingSize and ...

    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

    Wednesday, November 21, 2012 11:49 PM
  • User1706054173 posted

    1-

    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 ?

    and , you are right about redirectToWWW , I'm going to remove it .

    Thursday, November 22, 2012 12:25 AM
  • User-576912550 posted

    m_royasaz

    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 .

    Glad to know that my reply answered your query Smile

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 22, 2012 1:38 AM