Defensive programming (ie. checking object for null before having an action on it) can be a great tool but do we always can prevent all the errors especially when it comes to user inputs or web servers that not always reliable. When application is up and running there are not many ways we can find out that some user had an error unless the error is global so application goes down. Of course if we have an access to Windows Event Viewer on the server we can check it daily but in my honest opinion Event Viewer is quite hard to use. Instead of that we can write our own ErrorLogger. So each time user or server have a bug we will have a nice report on that. For error tracking we will use .NET built in Exception class and Try and Catch block.
Posts Tagged: ASP.NET
15
Sep 09
HOWTO: Use C# and VB in the same project
You will get a compilation error if you will place C# and VB code along in App_Code directory. This little code snippet for web.config gives your compliper an ability to distinguish between languages. Some of you could ask, i use X language why should i start an application with native support for few ? Real life example explains why would you do that.
14
Sep 09
HOWTO: Access Session outside of the page’s live cycle
You cannot access Session object or any other object which resides in page’s life cycle from out of the scope functions .This follow OOP rules but sometimes complicate development process when you need to access session from external source. In this example i will examine the way i use at any project to hack OOP for my needs. Maybe there is a better solution but this is the best i’ve found so far.
9
Sep 09
HOWTO: Limit Viewstate length
In some occasions browsers may block or truncate generated viewstate due to it’s length. This short tweak may solve the issue by dividing the viewstate to independent hidden fields based on the number you provide as value. In this example maxPageStateFieldLength set to 50 this means when viewstate get beyond 50 characters it will be broken to different hidden fields holding viewstate’s value