AppStart vs static constructor in ASP.NET WebPages -
i have static class in app_code
folder:
public static class sitedata { public static string adminemail{ get; set; } }
the class have static members shared among users. in example, used adminemail
.
i know 2 ways of initializing adminemail
:
solution 1:
create _appstart.cshtml (c#)
@{ sitedata.adminemail = "admin@mydomain.com"; }
solution 2:
create static constructor in sitedata
class
public static class sitedata { public static string adminemail{ get; set; } static sitedata() { adminemail = "admin@mydomain.com"; } }
both solutions initialize adminemail
@ application start. here questions:
1) solution more appropriate in situation?
2) advantages , disadvantages of both solutions?
3) use of appstart in asp.net if static class can task?
from can tell appstart.cshtml seems more integrated rest of webapp. http://www.asp.net/web-pages/tutorials/working-with-pages/18-customizing-site-wide-behavior plain static constructor have lot less knowledge of web environment
Comments
Post a Comment