Use FxCop with ASP.NET 2.0

Dec 28, 2006
The build process in ASP.NET 2.0 is very different than in ASP.NET 1.x, because it does not produce a dll file. That means that you cannot use FxCop because it can only work with dll and exe file types. However, there is a way to produce dll files from your web application within Visual Studio 2005 and those dll files can be used by FxCop. These are the steps to follow to make FxCop analyse your web application:Step 1 Create a new folder somewhere on the disk... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Remove nulls from a DataTable

Dec 21, 2006
The individual cells in a DataTable can have a null value in the form of System.DbNull.Value. If the DataTable is created by querying a database through ADO.NET, you can write the SQL statement in a way eliminates nulls. It could look like this “SELECT isnull(name, 'n/a') AS name FROM products”. However, there can be scenarios where you don’t have the chance to manipulate the DataTable before you use it. Such a scenario have I recently been involved in and the proble... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

List time zones in ASP.NET

Dec 19, 2006
If you need a list of time zones for your user to pick from, you probably want a dropdown list. Then you just need a list of time zones to bind to the dropdown list. Unfortunately, the System.TimeZone class doesn’t provide us with such a list and there is actually no where in the .NET Framework you will find it. It is very strange and also annoying because we are getting pretty used to find almost everything we need in the framework. This means that we have t... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Maintain scroll position after postbacks

Dec 18, 2006
To maintain the scroll position after postbacks is important for larger web pages in order to let the user know exactly what is going on. It is good usability and something you would expect in modern web applications. In ASP.NET 1.x you were able to do it simply by setting the SmartNavigation property to true on the page. The problem with SmartNavigation we numerous and did more harm than good. It was not cross-browser and it could mess up your own JavaScript. That’s ... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Let Windows place your temp files

Dec 16, 2006
Whenever you need to write files to a temporary location, you can take advantage of Window’s own temporary file store location. It has write permissions by default, which often is a problem for especially hosted websites and applications. The temp folder could be located here C:\Documents and Settings\Username\Local settings\Temp\ if the application is run under Windows user credentials. Because the location is not the same in all scenarios, you can ask .NET where the cur... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

A simple factory using Generics

Dec 14, 2006
For about a week ago one of my readers asked me to simplify a piece of his code. The code was translating the different tags used by blog comments, such as [url][/url], [img][/img] etc. as we know from WordPress. It was one big method that processed the different types of tags before the comment was saved to a database. I suggested a very simple factory design by using Generics and an interface. Then for each tag we would create a new class for handling only that single t... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Get the HTTP status code from a URL

Dec 13, 2006
Yesterday, I wrote about the Ping class for checking network availability on remote machines. Then I started thinking about checking the availability of web servers. Even if a remote server is available over the network, the web server instance might not response to requests so we need another method to check if it’s responding correctly. What we really want is not a Boolean value telling us if the web server is responding or not. The best way is to get the HTTP stat... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Using the Ping class

Dec 11, 2006
The Ping class is new to .NET 2.0 and it let’s you ping remote addresses much the same way as the ping.exe command line tool does. It’s a great way to check the availability of different kinds of remote servers over the network in a very low cost and fast way. The most important result a ping can give you is the ping time. The ping time gives you an indication on the network speed between you and the server. I’ve written a very small and easy to use method that return... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Asynchronous pages in ASP.NET 2.0

Dec 11, 2006
In ASP.NET 2.0 it is now possible to create asynchronous pages in a very simple and easy way. It gives you a whole new abstraction layer on top of the managed thread pool that let’s any webpage take advantage of multithreading. On high volume websites it means much higher performance. The single coolest thing about it is that you build the web pages as you normally would, but move some of the code into two separate methods. That means that there is no real learning curve, bec... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Remove HTML comments at runtime

Dec 6, 2006
I’ve been playing a bit with regular expressions lately and have to find some useful tasks in order to practice the skill. So, today I wanted to make a little method that strips HTML comments from an ASP.NET webpage at runtime. The practical use of the exercise is somewhat limited for most developers, but some websites have so many comments that it might just save a decent amount of bytes from the response stream. The problem with this exercise is that a lot of JavaS... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

About the author

Mads Kristensen

Mads Kristensen
Program Manager at the Microsoft Web Platform team and founder of BlogEngine.NET.

More...

Month List

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way.