Welcome to Julian Kuiters Friday, October 19 2018 @ 09:52 AM AEDT

How to hide a property from a datasource when binding in ASP.Net design view

.NET Programming

Creating your own custom classes for business objects and object datasources is a great way to provide and object model for databases.

But some classes might contain properties that you don't expect to show to end users when they are bound to a DataGrid, FormView or other databound control.

Luckily there is an attribute that you can attach to properties that you want automatically hidden from databound controls:


To hide a property from databinding simply place the Browsable(false) attribute immediately before your property declaration


 public int MyProperty {
    get {
       // Insert code here. 
       return 0;
    set {
       // Insert code here.

ASP.Net - Server operation is not available in this context - Using Server.MapPath in Global.asax

.NET Programming

If you try to use the Server.MapPath() function in your global.asax file for ASP.Net you are likely to encounter this error:

Server operation is not available in this context

To use Server.MapPath() in global.asax instead use:


More details about System.Web.Hosting.HostingEnvironment.MapPath() are available on MSDN

ASP.Net Tools to Test High CPU Load, High Memory and High Disk Usage

.NET Programming

Often when testing the performance of a ASP.Net website you need to see how the site will perform under extreme conditions. This is easy to do in a virtual environment where you can reduce the number of CPUs or available RAM.

But how do you test this on a physical box?

Vijayshinva Karnure has written a short list of tools that you can use to stress out the CPU, Memory and Disk outside of your ASP.Net application so you can look for memory / timeout / response problems

Check out the list here http://blogs.msdn.com/b/vijaysk/archive/2012/10/27/tools-to-simulate-cpu-memory-disk-load.aspx

A number of these tools come from the Windows SysInternals team who are all about performance

Keeping Exception.StackTrace Intact when Rethrowing an Exception

.NET Programming

Nick Weinholt (.Net Performance guru and MVP) has an article on the correct method for rethrowing an exception in C# so that the Exception.StackTrace actually points to the root problem.

In C# the correct method for rethowing an exception is using throw; without any arguments within the catch block:

try {
// code
catch (Exception ex) {
throw; // Rethrow exception without resetting StackTrace

In VB.Net the method is the same:

' code

Catch ex As Exception
Throw ' Rethrow exception without resetting StackTrace

End Try

Using this method the stack trace will go all the way down to the original exception, and not just to your catch block.