Posts Tagged: ASP.NET


21
Sep 09

HOWTO: Log website errors using exceptions in ASP.NET

Defen­sive pro­gram­ming (ie. check­ing object for null before hav­ing an action on it) can be a great tool but do we always can pre­vent all the errors espe­cially when it comes to user inputs or web servers that not always reli­able. When appli­ca­tion is up and run­ning there are not many ways we can find out that some user had an error unless the error is global so appli­ca­tion goes down. Of course if we have an access to Win­dows Event Viewer on the server we can check it daily but in my hon­est opin­ion Event Viewer is quite hard to use.  Instead of that we can write our own Error­Log­ger. So each time user or server have a bug we will have a nice report on that. For error track­ing we will use .NET built in Excep­tion class and Try and Catch block.

Con­tinue reading →


15
Sep 09

HOWTO: Use C# and VB in the same project

You will get a com­pi­la­tion error if you will place  C# and VB code along in App_Code direc­tory. This lit­tle code snip­pet for web.config gives your com­pliper an abil­ity to dis­tin­guish between lan­guages.  Some of you could ask, i use X lan­guage why should i start an appli­ca­tion with native sup­port for few ? Real life exam­ple explains why would you do that.

Con­tinue reading →


14
Sep 09

HOWTO: Access Session outside of the page’s live cycle

You can­not access Ses­sion object or any other object which resides in page’s life cycle from out of the scope func­tions .This fol­low OOP rules but some­times com­pli­cate devel­op­ment process when you need to access ses­sion from exter­nal source. In this exam­ple i will exam­ine the way i use at any project to hack OOP for my needs. Maybe there is a bet­ter solu­tion but this is the best i’ve found so far.

Con­tinue reading →


9
Sep 09

HOWTO: Limit Viewstate length

In some occa­sions browsers may block or trun­cate  gen­er­ated view­state due to it’s length. This short tweak may solve the issue  by divid­ing the view­state to inde­pen­dent hid­den fields based on the num­ber you pro­vide as value. In this exam­ple max­PageS­tate­Field­Length set to 50 this means when view­state get beyond 50 char­ac­ters it will be bro­ken to dif­fer­ent hid­den fields hold­ing viewstate’s value

Con­tinue reading →