Andrew's Blog

Random Thoughts of an ASP.Net Code Monkey

Students!!! - Get MS Office Ultimate 2007 for 39 Quid! An Absolute Steal!!

September 8, 2008 21:04 by Andrew Westgarth

I was recently reminded of this great offer which Microsoft have for Students, Office Ultimate 2007 is available for £38.95 which is an absolute steal!  I was reminded of this offer as my Brother is about to start a degree course at the University of Sunderland.  This is an excellent offer for any student out there!  For full details and eligibility details go to the Ultimate Steal Website this offer is also available in other countries too!


Categories: Microsoft
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Tutorial for Using ASP.Net MVC Framework on Different Versions of IIS

September 5, 2008 22:49 by Andrew Westgarth

Last night Alan Dean came up to VBUG in Newcastle to speak on ASP.Net MVC Framework.  One of the discussion points we had was any potential issues for hosting sites on IIS due to the routing and url rewrite elements of the MVC Framework.  I wasn't clear on the implications, and I hadn't seen much traffic personally on the issue.  So with a task of downloading ASP.Net MVC Framework Preview 5 so I could have a good look at it and understand it all as an alternative to Webforms, and looking into the implications and workarounds for hosting within versions of IIS I went of in search of information.

I immediately thought that with IIS7 and applications running in Integrated Mode, which is the mode I aim to run all of my applications on IIS7 in, there should be no configuration changes or modifications required since ASP.Net is part of the pipeline so all requests are processed by ASP.Net by default.  In classic mode ASP.Net requests are processed through the aspnet_isapi.dll as they would be in IIS6 so unless files are mapped to the ASP.Net Isapi filter then they wouldn't be processed.  In reading up about ASP.Net MVC on the ASP.Net website I found a great tutorial on Using ASP.NET MVC with Different Versions of IIS - hopefully this will be of help to you looking to configure and use the ASP.Net MVC Framework on IIS.

Categories: ASP.Net | How To | IIS
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Can't Save Your XSL/T File? Have You Closed Your XMLReader?

September 5, 2008 22:08 by Andrew Westgarth

Post Updated on Monday 8th September 2008 - See Below

This week I have been working on a server control for a site I'm working on which reads in an XML file containing some product information and then using an XSL/T file transforms the output into correctly formatted XHTML.  One problem which occurred with the development of the server control was that a colleague of mine who was making modifications to the XSL/T File was unable to save the changes whilst viewing the resultant XHTML in their browser.  At first hand it would appear that it would be a permissions issue, and after much checking of the permissions to confirm they were correct, it was determined this was not the issue. 

My colleague had been able to save changes to the XSL/T after a short while of the page processing which immediately pointed me to the fact that the object was still holding onto the resources.  This was further confirmed with some investigation work which I did with the help of Craig Murphy

The XMLReader object which was reading and transforming the XML using the XSL/T was still holding on to the file and placing a lock on it because the XMLReader object doesn't have a dispose method and so therefore despite my setting the object to nothing, until the garbage collector picked up the objects then the lock on the XSL/T file remained.  Craig suggested I call the XMLReader.Close() method after I had finished processing the XML, this was a method I wasn't aware of and had not seen used in any example when I did my research into the changed syntax since version 2.0 of the .Net Framework. 

Here is a code snippet below of an example of how to use the XMLReader.Close() method to release the locks on resources:

Dim strProductDataXML As String = "ProductData.xml"
Dim strProductDataXSLT As String = "ProductDataTransform.xsl"
Dim sb As New StringBuilder()
Dim sw As New StringWriter(sb)

' Create XSL CompiledTransform to hold XSLT
Dim objXSL As New XslCompiledTransform
' Create XsltSettings to hold XSLT Settings
Dim objXSLTSettings As New XsltSettings(False, True)
' Create XmlReader Object to read the XSLT
Dim objXSLReader As XmlReader
' Create XMLReaderSettings Object For XMLReader Object which will read the XSLT
Dim objXSLReaderSettings As New XmlReaderSettings()
' Create XMLSecureResolver for use with the XSLCompiledTransform
Dim objXMLResolver As New XmlSecureResolver(New XmlUrlResolver(), "")

'Create Reader Object to read the XSL Transform
objXSLReader = XmlReader.Create(HttpContext.Current.Server.MapPath("~/XSLT/ProductDataTransform.xsl"), objXSLReaderSettings)
' Load the Transform in the XSLCompiledTransform Object, Provide the settings and resolver objects
objXSL.Load(objXSLReader, objXSLTSettings, objXMLResolver)

' Set the Source of the ProductData XML File to be transformed
Dim xmlSource As New XmlTextReader(HttpContext.Current.Server.MapPath("~/XML/ProductData.xml"))
Dim xPathDoc As New XPathDocument(xmlSource)

' Call the close method on the XMLTextReader to release all resources which is attached too.

' Perform the Transformation and output it to a stringwriter object
objXSL.Transform(xPathDoc, Nothing, sw)
' Call the close method on the XSLReader to release all resources which is attached too.

' Set all objects to Nothing to allow the Garbage Collector to remove them
strProductDataXML = Nothing
strProductDataXSLT = Nothing
objXSL = Nothing
objXSLTSettings = Nothing
objXSLReader = Nothing
objXSLReaderSettings = Nothing
objXMLResolver = Nothing
xmlSource = NothingxPathDoc = Nothing

' Return the transformed string
Return sb.ToString()

Now that the XMLReader is closed and has released all of the objects holding on to it, the XSL/T file can be edited and changed without having to wait for the Garbage Collector to remove the objects and release the locks.


UPDATE - After reading the comments I have received on this post, I have tidied up the code and made use of the Using structure, to be honest I had forgotten this was available in VB.Net from version 2.0 of the Framework.  The use of the Using structure handles the disposal of the objects and therefore releases the locks on the resources the objects are using.  Below is the updated code sample:

Dim strProductDataXML As String = "ProductData.xml"
Dim strProductDataXSLT As String = "ProductDataTransform.xsl"
Dim sb As New StringBuilder()

' Create XSL CompiledTransform to hold XSLT
Dim objXSL As New XslCompiledTransform
' Create XsltSettings to hold XSLT Settings
Dim objXSLTSettings As New XsltSettings(False, True)
' Create XMLReaderSettings Object For XMLReader Object which will read the XSLT
Dim objXSLReaderSettings As New XmlReaderSettings()
' Create XMLSecureResolver for use with the XSLCompiledTransform
Dim objXMLResolver As New XmlSecureResolver(New XmlUrlResolver(), "")

objXSLReaderSettings.ProhibitDtd = False

'Create objXSL XMLReader Object to read the XSL Transform
Using objXSLReader As XmlReader = XmlReader.Create(HttpContext.Current.Server.MapPath("~/XSLT/" & strProductDataXSLT), objXSLReaderSettings)
    ' Load the Transform into the XSLCompiledTransform Object, Provide the settings and resolver objects    
    objXSL.Load(objXSLReader, objXSLTSettings, objXMLResolver)
    ' Set the Source of the ProductData XML File to be transformed    
    Using xmlSource As New XmlTextReader(HttpContext.Current.Server.MapPath("~/XML/" & strProductDataXML))
        Dim xPathDoc As New XPathDocument(xmlSource)
        Using sw As New StringWriter(sb)
            ' Perform the transformation and output it to a stringwriter object            
            objXSL.Transform(xPathDoc, Nothing, sw)
        End Using
    End Using
End Using

Return sb.ToString()

I'm sure you'll agree it's a lot cleaner and better structured.

Categories: How To
Actions: E-mail | Permalink | Comments (5) | Comment RSSRSS comment feed

Please Help Me Help Others - BUPA Great North Run 2008 and the Guide Dogs for the Blind

September 4, 2008 14:22 by Andrew Westgarth

On Sunday 5th October 2008 I will be taking part in the BUPA Great North Run and I am hoping to raise a sum of money to be donated to the Guide Dogs for the Blind

Why The Great North Run?

gnr_logoWhy not is my response :). It's so easy to sit at home and watch these events and say wouldn't it be great to do that! So I decided around December 2007 last year to investigate how to enter and submitted my entry form in January and paid my entrance fee, then I waited on tenterhooks to see if I got a place. Unfortunately I've had events in my life which have made me learn the very hard way that Life is Very Short and we should value every day of it. I am not hugely physical, I do play football two to three times a week but have never really been into running let alone 13.25 miles! So I looked upon the Great North Run as a challenge and something I could look back on and say I did that and at the same time hopefully help other people! I am setting myself a personal target of the time I want to achieve - if you don't have something to aim at you'll never reach the stars.   TRAINING UPDATE: I am now up to running 10 miles in one stint at a half decent pace so am well on the way to being ready :).

Why Guide Dogs for the Blind?

guide dogs blue logoWhen I looked at the long list of very worthwhile causes, I had a few milling around in my mind, with which I have had or have connections with in some form over the years, but Guide Dogs for the Blind was the one that sprung forward. Six years ago my Dad passed away, a dark and very stressful period in my life which rocked me too the core, and as part of the funeral we collected money for Guide Dogs for the Blind and just had family flowers. We chose Guide Dogs for the Blind then because my Dad always had a great love for dogs and in particular the Labradors and Retrievers which are synonymous with the Guide Dogs Organisation and so there we had a link. There were other charities we considered but we decided to help the Guide Dogs for The Blind.

Just a couple of weeks ago I was reminded of the great work that the organisation do and the amazing stories of how Guide Dogs help to change the lives of people are blind, when watching the Secret Millionaire on Channel 4. In this programme a gentleman in Glasgow had become blind after contracting a rare illness and to see how valuable his Guide Dog is and how it lets him live independently and how much love he has for the dog was very moving.  If you are in the UK I would very much recommend that you watch the program via Channel 4's online service - and you'll need to search for the Secret Millionaire - Nick Leslau.  Hopefully whatever amount I raise will be of help to the Guide Dogs for the Blind Organisation and will enable them to continue the great work that they do!  For more information about the Guide Dogs for The Blind visit their website

So how can you help me?

You can help me by sponsoring me via my JustGiving Page, and hopefully through my efforts in the Bupa Great North Run I can raise a sum of money which will be used by the Guide Dogs for the Blind to continue their great work! 

Developer Developer Developer Day 7 - Session Voting Open

September 1, 2008 14:50 by Andrew Westgarth

DDDLogo Craig Murphy via Twitter has just alerted me to the fact that session voting is now open for DDD7, go to the website now and select up to 10 sessions that you would like to see on the agenda for DDD7 -

RemixUK - Ready Steady Speak Competition! - Win an XBOX 360!

September 1, 2008 11:22 by Andrew Westgarth

Ready Steady Speak is back for the RemixUK Event in Brighton on Thursday 18th and Friday 19th of September 2008.  Are you a budding speaker? A Designer with a passion for what you do who would like to educate us Developers in how it's done or some other aspect of design which we really don't get?  Are you a Developer who wants to get his message across to designers about just how cool the latest features in Web Development Technologies are or do you just want to share your knowledge with your fellow designers and developers?  If so then Ready Steady Speak at RemixUK could be the ideal opportunity!

RemixUK is all about the conversation and the opportunity for Web Developers and Web Designers to mix and discuss their roles and technologies and work together to shape the future of the Web!.  Ready Steady Speak is a unique way for you to have a go at delivering a short presentation to a very receptive audience of like minded people, and hopefully once you get a taste you'll go on to deliver full presentations or more nugget style presentations at local usergroup events, Barcamps etc around the country!  I've presented at a number of events and conferences now and the Buzz is amazing - so I very much encourage you to have a go!  If you have any questions or doubts email me - using the contact form on this blog and I'll do everything I can to help you!

The full details of the RemixUK Ready Steady Speak Competition are:

Contestants will present a 5 min session on a subject of their choice relating to Web Development or Web Design.  They will present in front of the REMIX audience and in front of a panel of judges.  If there are more than a  certain number of contestants (TBD), there will be ‘heats’ earlier in the day with the winners of the heats in a ‘speak-off’ in the evening session.  The ‘speak-off’ will take place as stated in the evening of the first day of MIX and the first prize is an XBox 360 + Goodies! 



· Speakers must NOT have previously presented ‘full sessions’ at DDD, TechEd, DevWeek, SDN, SQLBITS, VBUG Conference, NxtGenUG FEST or any similar such conferences.

· Speakers must create a new session of their own with new material which can be based on existing material but cannot be a simple copy of it.

· Speakers must limit their session to as close to 5 mins as possible( overrunning time will cause the speaker to be marked down.)

· Speakers must not have previously won Speaker Idol or “Ready Steady Speak” UK Launch

· Speakers must state their desire to enter the competition by no later than COP Monday 15th September 2008 by email.


· Speakers should provide if at all possible their own laptop, but one can be provided if necessary.  The speaker should notify the organisers of any software prerequisites.

· Speakers should have spoken previously at a User Group meeting even if only for a 10 min mini-session or ‘nugget’.  This is NOT mandatory.


So come on and have go it'll be a great and very rewarding experience!!!  I'm really looking forward to making the very long trip down to Brighton and look forward to meeting lots of new great people!


VBUG Newcastle Event: Sept 4th 08 - ASP.Net MVC Framework Preview with Alan Dean

August 11, 2008 12:41 by Andrew Westgarth

Next month sees the resumption of the VBUG Newcastle meetings and I have Alan Dean coming up to deliver a session on the ASP.Net MVC Framework Preview.  I am looking forward to Alan's visit and seeing if he can convince me about MVC as I am still not convinced - it looks too much like old asp to me :o.

Details of the session:

Alan will be providing an introduction to the new ASP.NET MVC Framework Preview and, by way of association, usage of some new .NET 3.5 features such as LINQ. The talk will cover the MVC design pattern in outline, and demonstrate usage of the ASP.NET MVC Framework itself with a simple RESTful application

Alan Dean has been a professional developer for more than a decade, primarily in the retail sector, and is currently a Senior Technologist at Charteris. An unconventional thinker, he has been involved in REST and the semantic web for 7 years. He is also a committed extreme programmer and one of the Alt.Net UK Conferences organisers.

Location: Castle Gate, Melbourne Street, Newcastle-upon-Tyne, NE1 2JQ, GB

Registration is free, please register on the VBUG website

I look forward to seeing you there!  Also I have some good sessions in the plans for Newcastle for the rest of the year.  If you are based in the North East and attend user group meetings and would like to see a topic covered, let me know and I'll see what I can do.

Categories: Events | VBUG
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

MSDN and TechNet UK Events

August 11, 2008 12:11 by Andrew Westgarth

Here are a list of forthcoming MSDN and TechNet events this autumn in the UK, unfortunately there aren't any in the North East this time as yet.

MSDN Events

TechNet Events

Manic Miner Now in SilverLight!!

August 10, 2008 19:51 by Andrew Westgarth

Richard Costall of NxtGenUG has just sent through the details of an implementation of Manic Miner, the old Spectrum Classic, that has been completed in Silverlight.  I started with the C16 and C64 and never had a Spectrum but will be looking forward to having a go with this.  If you had a Spectrum or loved the game, this is a must.  Here are the details from Richard:

NxtGenUG Silverlight Manic Miner

NxtGenUG Co-Founder Richard Costall & Member Pete McGann are pleased to announce their “Silverlight” Manic Miner game Beta is now live on the NxtGenUG site. Manic Miner was originally written by Matthew Smith, under games company Bug-Byte in 1983. The game was a landmark title in the history of gaming.

The original classic features 20 caverns to negotiate, and Pete and Rich had lovingly created 9 of these so far, with more to follow shortly.

Silverlight Manic Miner shares a custom built ‘time based’ engine with an XNA version of the game. A library of c# files is shared between the two systems. The Silverlight edition is also integrated into the NxtGenuG site, through Application services, and registered visitors can have their high scores recorded and shown in a leader board which refreshes every 60 seconds.

Pete and Rich will be telling their story at NxtGenUG Coventry on August  11th 2008

Silverlight, XNA and Gaming
Matthew Smith did it in 6 weeks in the early 80's, now over 20 years later Pete McGann and Richard Costall have built Manic Miner in .NET, with an engine which works for Silverlight and also XNA. In this session Pete and Rich, talk about the .NET engine, implementations and issues on the two platforms - before Pete steps up to take the ultimate gaming challenge...

Creating Http Redirects in IIS7 on Virtual Directories like IIS6

July 31, 2008 18:04 by Andrew Westgarth

In IIS6 when creating a virtual directory it was possible to set the virtual directory to actually add as a redirect to another page or site.  In IIS7 this is still possible however it needs to be achieved slightly differently.  Lets take an example.  Say you have a website and you are running a number of offers and would like to offer users the option of navigating to them through a short path such as domain/offer1, domain/offer2 etc then you would have in IIS6 set these Virtual Directories up with dummy Physical Paths, e.g. the root of the parent site, and set the option to redirect to a URL.

In IIS7 because the configuration is stored in a web.config file in the physical path of the virtual directory, this can cause the redirections to be overwritten, i.e. if you set up the redirection of domain/offer1 to go to domain/offers/offer1 and then go and set up domain/offer2 to go to domain/offers/offer2 you will find that both redirections go to domain/offers/offer2 because the value in the web.config file has been overwritten by the second redirect rule.  In order to achieve the desired effect and get the redirections to work, you need to actually add the redirections to the applicationhost.config file and set a location tag for the site you are working in.  This is currently not possible in the User Interface but is possible to achieve using the APPCMD utility.  Here are the steps to achieve this.

1. Open an elevated command prompt

2. then run the following command -

%windir%\system32\inetsrv\appcmd set config "nameofsite/virtualdirectoryname" -section:system.webServer/httpRedirect -enabled:true -destination:destinationofredirect -commitpath:apphost

an example of this command would be:

c:\windows\system32\inetsrv\appcmd set config "Default Web Site/offer1" -section:system.webServer/httpRedirect -enabled:true -destination:Offers/Offer1/default.aspx" -commitpath:apphost


The key element here in this command is the commitpath directive which adds sets the configuration in the applicationhost.config:

<location path="Default Web Site/Offer1">
    <httpRedirect enabled="true" destination="Offers/Offer1/default.aspx" />"


Hope this clears it up :).

Categories: How To | IIS
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed


Post calendar

<<  February 2016  >>


The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2016