Refactor the code before you write it

Nov 30, 2006
Have you ever heard the saying “If you don’t know where to look, don’t look at all”? Think about this saying and coding. If a piece of code somewhere in the system is causing an error, don’t split the whole thing apart to find it. Know where to look for it before you cause even more damage. The same principle can be applied to new features, functions or methods you want to create in your application. You know exactly how the feature has to work and you start coding. A... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

An HttpModule that moves ViewState to the bottom

Nov 28, 2006
There are two reasons why it is desirable to do so. The first is for letting search engines see more of your content rather than the big portion of ViewState many sites have. The other is perceived rendering time, which means that the content loads faster because it renders before the ViewState while the total rendering time remains the same. That will decrease the load time of your website’s content. Techniques to move the ViewState to the bottom of the WebForm has ... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Brute force protect your website

Nov 27, 2006
On a website with the ability for users to logon, it is a good idea to have some sort of password policy. The most widely used contains minimum requirements for the length of the password and that the individual characters must be a mixture of numbers, letters and special characters. This is pretty much standard and they make it much more difficult to break into your system. Eventually, these passwords will be broken and for a brute force robot it’s only a matter of t... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Combine accessors in C#

Nov 27, 2006
Today I had to add some functionality to an already existing class library. In there were a internal virtual method that I thought were supposed to be protected virtual. To no big surprise, I couldn’t compile after changing it to protected. I didn’t want to make it public so I thought of combining the two accessors with no hope for it to work. internal protected virtual void SomeMethod() {   DoSomething(); } ... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Using the W3C HTML Validator API

Nov 22, 2006
The W3C has introduced an API for their HTML Validator. It is not a SOAP web service, but it does return XML that can be parsed, so now you have the ability to incorporate validation to any web application, Windows program or wherever you want. It works just as the normal validator, by specifying a URL, but you have to add the “output=soap12” parameter to the URL like so: http://validator.w3.org/check?uri=http://www.google.com&output=soap12. I’ve been playing a littl... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Add multiple classes to HTML elements

Nov 21, 2006
I recently realized that you can add more than one class to a single HTML element. This opens up to even more structured stylesheets and more code reuse. It’s a standard and has cross-browser support. You simply just separate the classes by a space like so: <div class="warning headline"> The nice thing about this is that you can refactor your stylesheet even more and thereby avoid duplication. .warning{   color: red; ... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Is ASP.NET too difficult?

Nov 20, 2006
There is no doubt in my mind, that ASP.NET is the most powerful and versatile platform for web applications at the moment. By leveraging the .NET Framework you can do absolutely anything in no time, but is that power also the problem with ASP.NET? In the dark ages before ASP.NET, we were stuck with ASP and PHP but we were just as enthusiastic about them as we are with ASP.NET now. They were relative easy to learn and to learn well enough to do something really cool with i... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Pull a prank on your co-workers

Nov 17, 2006
Office pranks are among the funniest and we’ve probably all done some of our own over the years. This time, my boss and I came up with a good one. Write an add-in for Windows Live Messenger that auto replies to all incoming messages. We would then install it on a co-worker's computers when he goes to lunch. We would define some sentences that by random is sent to the sender of any incoming message. Building the add-in To our big surprise, this was the ea... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Remove unused objects from the session

Nov 16, 2006
The Session in ASP.NET is a very simple way of storing user specific data for the duration of a single user session. I’ve many times added data to the Session that had an even shorter lifespan. That could be as a data store for properties on AJAX enabled web pages and those properties don’t belong in the session after the visitor navigates to another page on my website. To clean up, I would then delete those session objects that no longer is in use. There are two way ... [More]* $4.95/month ASP.NET Hosting with FREE SQL 2012 DB! – Click Here!

Tip for localized websites and the html tag

Nov 14, 2006
For a website that supports multiple languages, it is important to tell the client what the selected language is. This is done in the <html> tag in the lang or xml:lang attribute and could look something like this for an XHTML document: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> The DOCTYPE and <html> t... [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.