Application web.config timeout being ignored

by Peter Taylor 11. July 2011 10:14

I was having a problem with a new ASP.NET 2010 site, when a user logged in and the authentication timeout was set to.

 

<forms timeout="1440" slidingExpiration="true" />

 

but after 10 minutes the site would log the user out.

This issue had never happened on ASP.NET 2008.

 

My test rig was Windows Server 2008 R2 with IIS and .NET4, and it showed no sign of this issue.

The issue only showed when it was deployed to the customers site where is was running on a Windows Server 2003 server with IIS and .NET4

 

 

It turns out that when IIS recycles the sessions for .NET4 applications on Windows Server 2003 machines, it also updates the machine key.

The machine key is a core part of the authentication cookie and when the key is reset the current cookie becomes invalid, logging the users out.

 

 

The fix is to generate your own machine key and state it in your web.config, this will stop the changing key as ASP.NET will use the web.config version.

 

The Machine Key tag

<machineKey validationKey="##" decryptionKey="##" validation="SHA1" decryption="AES" />

 

Milan Negovan has a tool on his website, allowing you to generate keys for the machineKey.

Tags:

Programming | ASP.NET

Generate full database SQL Scripts

by Peter Taylor 1. June 2011 21:50

If you ever need to make a copy of a SQL database without the data, or hold a copy of a script capable of building an empty copy on new servers, then the Generate Scripts option is a very handy tool.

In my role as a software developer, I use these scripts to create a blank copy of my development databases on the customer’s servers. I also keep a copy of all previous version of the database script, as it allows me to create an older database structure if needed.

 

The following screenshots are of “Microsoft SQL Server Management Studio 2008 R2” Right click on the database that you want to generate the script for and select “Tasks” then “Generate Scripts”

 

I recommend that you select “Select specific database objects” and then click “Select All”

 

You now have several options for how you want the scripts to be saved.

 

Click “Advanced” to set some scripting options

 

The important options are: 

Include IF NOT EXISTS
Adds a check to the script what will only create new objects if they don’t currently exist.

Script for SQL Version
Allows the script to be compatible with previous versions of SQL (2000, 2005, 2008 & 2008 R2)

Script USE Database
Add a parameter that makes sure that the database affected by the scripts is the correct one. I keep this off as this allows the script to create a copy of the database with a different name.

Types of data to script
This option will choose if the script is to be just the structure of the database or if it should include the data within.

Script Indexes
Sets the script to generate any indexes that you have setup on the database.

Tags:

SQL

RecentPosts