Just a quick easy reference for using C# Razor in asp.net mvc views:
http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx
Just a quick easy reference for using C# Razor in asp.net mvc views:
http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx
Joel Splosky has a very good and quite long article about “making bad code look bad.”
The concept is this, if you write code that adheres to good standards, then it’s easy for someone to read your code, and more importantly, discover bad practices without digging through all the code line by line to find out if you are doing something wrong.
I’ve been using this tool for some time on a number of projects. SlowCheetah allows you to transform your config files at build time based on the build type. So when you do a Debug build, you can include values that are meant for your dev environment, while at the same time doing a Release build will use values meant for production.
Very nice.
I’ve recently started using Hg for my source control. This tutorial has been very helpful in understanding the different ways you might choose to do branching.
Overall I’m liking Hg much more than TFS. It’s very fast and works locally. Makes my life very easy when moving between branches or changesets. Also, shelving works much better IMO.
This is a pretty cool looking tool from the Stack Exchange people called MiniProfiler.
You just add some profiling info to your code like this:
using (profiler.Step("Doing complex stuff")) { using (profiler.Step("Step A")) { // something more interesting here Thread.Sleep(100); } using (profiler.Step("Step B")) { // and here Thread.Sleep(250); } }
and see the result live in the browser like this:

Here are some great articles talking about properly enabling compression in IIS6.
I had made some of these changes in the past, but I noticed that they had since been overwritten or not persisted. I believe with the changes to the metabase file it will help keep the compression working.
http://blog.grushin.com/2008/04/21/iis6-compression-including-js-css-etc/
http://blog.grushin.com/2008/04/21/iis6-compression-file-extensions-and-testing/
Last year, I donated a weekend of my time to work with some other developers to create a new site for Bear Necessities Pediatric Cancer Foundation.
When we wrapped up work, the site was nearly completed, with a few ends to tie up, and of course, all the content needed to be entered and hosting setup and DNS ….. you get the idea.
So FF a many months and I was starting to think that the site would never go live. Well it finally did.
It isn’t the most beautiful site (we didn’t have any graphic artists on the team) but it’s waaaaay better than what they had.
I’ve been getting this error every now and then.
Usually this problem is caused by having 2 controls with the same name. It can be that they are in different folders as well.
I came across this post today:
http://personalinertia.blogspot.com/2007/06/there-bug-in-compiler.html
Well, a quick search online told me that this might be a result of a known bug in the compiler. The fix was easy, you have to compile your app in non-batch -mode. How do you do this, I hear you asking. Simple: enter the compilation section of your web.config, and set batch=”false”, as so:
<compilation debug=”true” batch=”false”>
…
</compilation>
In SQL Server 2005 and newer you can create database catalog wide triggers that you can use to track all schema changes to any objects in that database.
I wanted to track all schema changes to all catalogs on my server, so what I did was to create a database catalog called SchemaChangeLog that contained a table and a SP as follows:
USE [SchemaChanges]
GO
/****** Object: Table [dbo].[SchemaChangeLog] Script Date: 01/27/2011 11:17:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[SchemaChangeLog](
[SchemaChangeLogId] [int] IDENTITY(1,1) NOT NULL,
[EventType] [varchar](100) NULL,
[PostTime] [datetime] NULL,
[LoginName] [varchar](100) NULL,
[Username] [varchar](100) NULL,
[DatabaseName] [varchar](100) NULL,
[SchemaName] [varchar](100) NULL,
[ObjectName] [nchar](100) NULL,
[ObjectType] [varchar](100) NULL,
[SqlText] [varchar](max) NULL,
[ServerName] [varchar](100) NULL,
CONSTRAINT [PK_SchemaChangeLog] PRIMARY KEY CLUSTERED
(
[SchemaChangeLogId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
USE [SchemaChanges]
GO
/****** Object: StoredProcedure [dbo].[SchemaChangeLog_Save] Script Date: 01/27/2011 11:17:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Chris May
-- Create date: 1/27/11
-- Description: saves schema change info
-- =============================================
CREATE PROCEDURE [dbo].[SchemaChangeLog_Save]
@data XML
AS
BEGIN
BEGIN TRY
insert INTO schemachanges.[DBO].SchemaChangeLog
(
[EventType],
PostTime,
ServerName,
LoginName,
Username,
DatabaseName,
SchemaName,
ObjectName,
ObjectType,
SqlText
)
VALUES (
@data.value('(/EVENT_INSTANCE/EventType)[1]', 'sysname'),
GETDATE(),
@data.value('(/EVENT_INSTANCE/ServerName)[1]', 'sysname'),
@data.value('(/EVENT_INSTANCE/LoginName)[1]', 'sysname'),
@data.value('(/EVENT_INSTANCE/UserName)[1]', 'sysname'),
@data.value('(/EVENT_INSTANCE/DatabaseName)[1]', 'sysname'),
@data.value('(/EVENT_INSTANCE/SchemaName)[1]', 'sysname'),
@data.value('(/EVENT_INSTANCE/ObjectName)[1]', 'sysname'),
@data.value('(/EVENT_INSTANCE/ObjectType)[1]', 'sysname'),
@data.value('(/EVENT_INSTANCE/TSQLCommand)[1]', 'VARCHAR(max)')
) ;
END TRY
BEGIN CATCH
-- we just don't want any errors here
END CATCH ;
END
GO
Then on each database catalog you want to track schema changes on, just run this to create the trigger:
create TRIGGER Trigger_Track_Schema_Changes ON DATABASE
FOR DDL_DATABASE_LEVEL_EVENTS
AS
SET NOCOUNT ON
DECLARE @data XML ;
BEGIN TRY
SET @data = EVENTDATA() ;
EXEC SchemaChanges.dbo.SchemaChangeLog_Save @data
END TRY
BEGIN CATCH
-- we just don't want any errors here
END CATCH ;
go
If you want to undo this you can always drop the trigger by using:
drop TRIGGER Trigger_Track_Schema_Changes ON DATABASE
EDIT: I’ve found that some things (like some actions in SQL Compare) cause this trigger to throw an error. I’m not sure why. But, if you want to just disable the trigger for a moment you can run this:
disable trigger Trigger_Track_Schema_Changes on database
Say you have a VHD from some VM but you really don’t want (or can’t) spin up the VM to access the drive. Well you can just mount it up in windows 2008 using Disk Management inside Computer Management.
Very handy.