July 2008 - Posts

Upcoming talks: Microsoft Tech Ed South Africa

In just a couple of weeks I'll be in Durban, South Africa presenting three sessions at Tech Ed. These are the sessions:

WEB304: Introduction to MVC Web Development

Day: Monday, 04 August 2008, 09:15 - 10:30
Location: Session Room 07
One of the benefits of using a MVC methodology is that it helps enforce a clean separation of concerns between the models, views, and controllers within an application. In the very near future, ASP.NET will include support for developing Web applications using an MVC-based architecture. The MVC pattern can also help enable red/green test-driven development (TDD) where you implement automated unit tests, which define and verify the requirements of new code, before you actually write the code itself. Join us for a dive into the new MVC Framework and learn how to leverage this new alternative in your own applications.

WEB306: What's new in Visual Studio 2008 for ASP.NET developers

Day: Monday, 04 August 2008, 16:15 - 17:15
Location: Session Room 08
Check out the latest and greatest with Microsoft Visual Studio 2008. From the CSS designer to JavaScript Intellisense, Visual Studio 2008 packs a powerful punch for building rich web applications. You’ll also see how to use LINQ data access and unit testing in a web application.

WEB307: A Tour of What’s New in ASP.NET 3.5

Day: Tuesday, 05 August 2008, 16:45 - 17:45
Location: Session Room 07
Discover how you can take advantage of the latest enhancements to ASP.NET and Visual Studio 2008 for building Web applications in your real-world applications. Enhance your web application with AJAX, Silverlight, and LINQ data access. You’ll also see how to use ASP.NET Dynamic Data to build a data entry site in a matter of minutes.

* Dates, times, and locations can change, so check your schedules!

I hope to see some of you there, so please stop by and say hi!

Posted by Eilon with no comments
Filed under: , , ,

HttpContext.IsCustomErrorEnabled - One of ASP.NET's hidden gems

Calling a property a gem might be a bit of an exaggeration, but this particular property is still rather valuable. In many situations a developer wants to enable a feature or part of a feature only for debugging and testing purposes. The IsCustomErrorEnabled property combines three values to tell you whether custom errors are enabled for a particular request. This isn't as simple as reading the web.config file to check the <customErrors> section. There's a bit more going on behind the scenes to truly determine whether custom errors are enabled.

The property looks at these three values:

  1. The web.config's <deployment> section's retail property. This is a useful property to set when deploying your application to a production server. This overrides any other settings for custom errors.
  2. The web.config's <customErrors> section's mode property. This setting indicates whether custom errors are enabled at all, and if so whether they are enabled only for remote requests.
  3. The HttpRequest object's IsLocal property. If custom errors are enabled only for remote requests, you need to know whether the request is from a remote computer.

The property is used in several places in ASP.NET to determine what type of error message to display to the user. When custom errors are enabled, the error messages tend to be terse so as not to disclose any secret information. When custom errors are disabled, more extensive information is displayed to the user including stack traces, type names, and file paths. One of the nice things about this property is that it works in all trust levels (well, at least Medium trust and higher - I'm not sure about Low and Minimal). It's also nice that you don't have to worry about reading from web.config manually.

Just recently in ASP.NET MVC we added a feature where we used this property to determine whether to show a generic error message such as "Your site is broken!" instead of full stack traces and debugging information. I hope this property ends up getting called by your ASP.NET applications and controls!

Posted by Eilon with 8 comment(s)
Filed under:
More Posts