Archive for the ‘Best Practice’ Category

Top 10 Best Practices for Production ASP.NET Applications

Post date: February 18, 2008

I found the following top 10 tips on daptivate.com. This tips are indeed exceptionally important to heed when moving from a development environment to a production environment. daptivate.com is the weblog of Kyle, a developer at Telligent

His tips are as follows:

1. Generate new encryption keys

When moving an application to production for the first time it is a good idea to generate new encryption keys. This includes the machine validation key and decryption key as well as any other custom keys your application may be using. There is an article on CodeProject that talks about generating machineKeys specifically that should be helpful with this.

2. Encrypt sensitive sections of your web.config

This includes both the connection string and machine key sections. See Scott Guthrie’s post for some good references. Note that if your application runs in a clustered environment you will need to share a custom key using the RSA provider as described in an MSDN article.

3. Use trusted SQL connections

Both Barry Dorrans and Alex Chang have articles which discuss this in detail.

4. Set retail=”true” in your machine.config

This will kill three birds with one stone. It will force the ‘debug’ flag in the web.config to be false, it will disable page output tracing, and it will force the custom error page to be shown to remote users rather than the actual exception or error message. For more information you can read Scott Guthrie’s post or the MSDN reference.

5. Create a new application pool for your site

When setting up your new site for the first time do not share an existing application pool. Create a new application pool which will be used by only by the new web application.

6. Set the memory limit for your application pool

When creating the application pool, specifically set the memory limit rather than the time limit which is set by default. Asp.net has a good whitepaper which explains the value of this:

By default IIS 6.0 does not set a limit on the amount of memory that IIS is allowed to use. ASP.NET’s Cache feature relies on a limitation of memory so the Cache can proactively remove unused items from memory.

It is recommended that you configure the memory recycling feature of IIS 6.0.

7. Create and appropriately use an app_Offline.htm file

There are many benefits to using this file. It provides an easy way to take your application offline in a somewhat user friendly way (you can at least have a pretty explanation) while fixing critical issues or pushing a major update. It also forces an application restart in case you forget to do this for a deployment. Once again, ScottGu is the best source for more information on this.

8. Develop a repeatable deployment process and automate it

It is way too easy to make mistakes when deploying any type of software. This is especially the case with software that uses configuration files that may be different between the development, staging, or production environments. I would argue that the process you come up with is not nearly as important as it being easily repeatable and automated. You can fine tune the process as needed, but you don’t want a simple typo to bring a site down.

9. Build and reference release versions of all assemblies

In addition to making sure ASP.NET is not configured in debug mode, also make sure that your assemblies are not debug assemblies. There are of course exceptions if you are trying to solve a unique issue in your production environment … but in most cases you should always deploy with release builds for all assemblies.

10. Load test

This goes without saying. Inevitably, good load testing will uncover threading and memory issues not otherwise considered.

Kyle has awesome content on his blog and I think there’s something for everyone there. I have sat reading different posts for the last half an hour or so. I habe already added his blog to my Google Reader. So go check out his blog now!

Top 10 Best Practices for Production ASP.NET Applications on http://daptivate.com

VS2008 UserControl does not follow best Practice

Post date: September 20, 2007

Craig Nicholson found this bug while working with Visual Studio 2008 Beta 2 today. Help us get Microsoft to fix this before the Visual Studio 2008 release as this is extremely important. You vote here.

Why do I say this is extremely important? I have recently started delving into the world of Best Practice which I must has been an eye opening experience. When it comes to something like user controls, we as developers are generally lazy sods and we like using shortcuts. A company like Microsoft knows this and when it comes to built in controls they need to be leading the way in implementing Best Practice.

Best Practice is something a lot of developers know very little about and most of them aren’t too bothered by it. The general consensus is that if it works then its fine. This is a notion that we must get out of our heads! If developers at Microsoft are too lazy to follow things like this then why would the average developer out there care? So take the time and vote for this! head over to CraigN’s blog and show your support!

Blogged with Flock

Shift in mentality

Post date: September 9, 2007

In all honesty, I’m still a beginner when it comes to developement. I only just have over 2 years experience. After attending an SaDev meeting recently and hearing about NHibernate for the first time I decided to check it out. Someone then suggested that I look into ActiveRecord instead. ActiveRecord is an O/R mapper that encapsulates the NHibernate framework and it seems much easier to work with. (More coming on this topic shortly)

While reading up on these things I started spotting certain things. I started reading up on different design models.

1) Database Driven Design
2) Domain Driven Design
3) CRUD (Create, Read, Update, Delete) Design
4) Extreme Programming
5) Agile Programming
6) Waterfall Model
7) Feature Driven Developement

Now to most of you with degrees, and honurs and whatever else, this is probably some standard ideas and methodologies but to me they are things I’ve never really looked into. I’ve now started spending more and more time reading on methodologies and design practices than actual developement articles! I’m starting to feel that maybe I should start looking into architecture even more. I think part of this also started last week when I received my best practice books from BB&D.

Sadly though, I registered on http://www.saarchitect.net/ and the forums there seem quite dead. I’m going to try contact some guys from the forums for help and more information on certain topics.

Blogged with Flock