Do more with your ASP.NET Page Template
page 7 of 9
by Sajid Rehman
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 30730/ 76

How do I do it? Error handling
Error handling features can be provided in your Page Template by –
  • Including an ErrorCode property in your PageTemplate class.
  • Add a method SetErrorCode(int code) that sets the above property & redirects to your error page. This method can be called from the code-behind when an error/exception is encountered.
  • Your error page would then be able to retrieve the error code by

int errorCode = ((PageTemplate)Context.Handler).ErrorCode;

This error code can be used to retrieve the appropriate error message from the resource file.


  • Ensures that all developers in the team handle errors/exceptions consistently – thereby saving time during integration.
  • Ensures that redirection to an error page, error logging, & error display happen in exactly the same way across pages & developers.

View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2021  |  Page Processed at 2021-03-02 10:13:33 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search