Friday, June 25, 2010

IE8 security warning when mixing http and https content

Ran into an issue with IE8 showing the following prompt with every page view under SSL.

Security Warning
Do you want to view only the webpage content that was delivered securely?
This webpage contains content that will not be delivered using a secure HTTPS
connection, which could compromise the security of the entire webpage.

Turns out the addition of the Microsoft AJAX CDN service is the cause in this particular case. Changing the script link to use SSL resolves the issue.

Wednesday, June 23, 2010

Programmatic log4net configuration at runtime

I've been looking for a way to enable/disable a log4net appender at runtime through code. Doing so would remove the need to remote to the production web server to alter the logging config file.

The blog post Tweaking log4net Settings Programmatically has a extension method to perform actions on certain types of appender.

Tuesday, June 22, 2010

Visual Studio 2010 CSS colour picker

Came across a Colour picker dialog for use when editing CSS files in the Visual Studio 2010 editor.

Right click on the style and select Build Style or
Styles (Menu) > Build Style

Thursday, June 17, 2010

Disabling a Trigger for a LINQ to SQL DataContext

I have a trigger on a table that fires on updates and adds a record to another table indicating that it needs to be rolled up to an external system. In a few cases I need to dynamically suppress this trigger to prevent circular updates between the two systems. My data access is via LINQ to SQL for the system in question.

The article Disabling a Trigger for a Specific SQL Statement or Session deals with the same problem.

using(DbDataContext dc = new DbDataContext())
{
 //Update fields etc...

 dc.Connection.Open();
 //Set the context_info here within the open connection so that it is in-scope 
 //for the triggers
 dc.ExecuteCommand("SET Context_Info 0x55555");
 dc.SubmitChanges();
 dc.Connection.Close();
}
 CREATE TRIGGER TR_Mock ON dbo.TableForTrigger FOR UPDATE
 AS 
 DECLARE @Cinfo VARBINARY(128) 
 SELECT @Cinfo = Context_Info() 
 IF @Cinfo = 0x55555 
 RETURN 
 PRINT 'Trigger Executed' 
 -- Actual code goes here
GO  

See Also:

Wednesday, June 16, 2010

ASP.NET Check if the current user can access a URL/Page

A method to verify that the user from the current HttpContext has sufficient roles to access a URL identified from the SiteMap.

  /// 
  /// Can the current User access the given URL according to the SiteMap (role trimmed)
  /// 
  /// URL to check. Can start with ~. Should not include query string parameters.
  /// True if the user has access.
  public static bool CanAccessUrl(string url)
  {
   SiteMapProvider provider = SiteMap.Provider;
   HttpContext current = HttpContext.Current;
   string rawUrl = VirtualPathUtility.ToAbsolute(url);
   SiteMapNode node = provider.FindSiteMapNode(rawUrl);
   return (node != null &&
    provider.IsAccessibleToUser(HttpContext.Current, node));
  }

Friday, June 11, 2010

TFS - Undo Checkout of Unmodified files

I've added a handy console command from the Team Foundation Server Power Tools to the end of our code generation batch file to undo checkouts on any file that hasn't actually changed.

This way the code generator can work blindly off the data source and the change set only contains the files that have actually changed.

tfpt uu "C:\Development\ProjectRoot" /noget /recursive

See also:

Thursday, June 10, 2010

Nelson .NET User Group Presentation - Common TSQL Programming Mistakes - 25th of June

Upcoming presentation

Dave Dustin from the AucklandSQL user group will be giving a presentation on TSQL.

Title:
Common TSQL Programming Mistakes

Abstract:
We are going to examine a variety of mistakes to which many developers fall prey - some obvious, some fairly subtle and some just plain evil! Coupled with this, we’ll be investigating some simple, and some not so, tips for increasing performance from your data layer.

Useful links:

When:
Friday 25th June 2010
Gather at 11:50 am, starting at 12:00 pm.
Approximately 1 hour plus pizza afterwards.

Where:
FuseIT Ltd,
Ground Floor,
7 Forests Rd,
Stoke,
Nelson
(Off Nayland Rd and behind Carters)

http://local.live.com/default.aspx?v=2&cp=-41.299774~173.236231&style=r&lvl=16&alt=-1000
or
http://maps.google.com/?ie=UTF8&om=1&z=17&ll=-41.299774,173.236231&spn=0.005239,0.010042&t=h

If you are parking on site, please use the parks marked FuseIT that are at the back of the site.

Catering: Pizza & Drinks
Door Charge: Free

RSVP to me if you are going to attend so I can guesstimate the food and drink requirements.

However, feel free to turn up on the day though if you can't commit at the moment.

Please feel free to invite anyone who may be interested in attending.