Categories
ASP.NET Software Engineering

Caching Method Results in ASP.NET 2.0 using Delegates

Hmm. Talk about over-engineering. I don’t think we really need generics at all, provided we’re happy with a cast outside the method instead of inside it.

public delegate object MethodExecution();public static object GetCachedMethod(string key, DateTime absoluteExpiration, MethodExecution method){    if (HttpContext.Current.Cache[key] == null)        HttpContext.Current.Cache.Insert(key,            method(),            null, absoluteExpiration, Cache.NoSlidingExpiration);

    return HttpContext.Current.Cache[key];    }...return (DataSet)GetCachedMethod(key, DateTime.Now.AddDays(1),                delegate() { return SomeMethodThatReturnsADataSet(myParam); });… Read more “Caching Method Results in ASP.NET 2.0 using Delegates”

Categories
ASP.NET Software Engineering

Caching Method Results in ASP.NET 2.0 using Generics & Delegates

Today I found myself coding a fairly familiar pattern – checking whether there was an entry in the ASP.NET cache with a particular key, if not, executing a method and adding the result to the cache, and either way, returning the result.

I wondered whether there was a “nice” way to do this using generics and anonymous delegates. This is … Read more “Caching Method Results in ASP.NET 2.0 using Generics & Delegates”

Categories
Software Engineering

Re-setting Identity Column in SQL Server

Discovered something new today – normally I’d just use the TRUNCATE TABLE command in order to reset an identity column in a table within SQL Server. However, SQL Server doesn’t let you do this if you’ve got foreign key constraints pointing at the table; so instead, I deleted all the rows using a standard DELETE statement, and then reset the … Read more “Re-setting Identity Column in SQL Server”

Categories
Software Engineering

Atlas Preview Website Live

It looks like the Atlas preview site is now live at http://atlas.asp.net/ … time to start getting my AJAX slides updated!

Categories
Software Engineering

Visual Studio 2005 RC

Visual Studio 2005 RC is now available to MSDN Subscribers. That’s all! :,,)

Categories
ASP.NET Software Engineering

Dynamically loading an IBindableTemplate

Want to dynamically load your two-way data bound templates rather than having to specify them inline? Well, unfortunately there’s no LoadBindableTemplate method in ASP.NET 2.0, but I’ve described a possible workaround at http://www.developerfusion.co.uk/show/4721/.

I also demonstrate how you can use this to load one portion of a two-way data bound template from one file (ie a common set of input … Read more “Dynamically loading an IBindableTemplate”

Categories
C# Software Engineering

*New* UK Windows Forms Mailing List

After some discussion over at the MsWebDev mailing list, I’ve now decided to launch an equivalent list for UK developers that want to discuss Windows Forms related and other .NET topics.

For more information, go to http://www.developerfusion.co.uk/mailinglists/winforms.aspx. Eventually we hope to offer NNTP and searchable Forum access to this courtesy of Community Server too.

Please spread the word!

Categories
Software Engineering

VS 2005 Release Dates & UK Prices

Microsoft have now announced the UK (non-volume licensing) pricing of Visual Studio – see http://msdn.microsoft.com/howtobuy/vs2005/subscriptions/Default.aspx and the following release dates:

MSDN Subscriptions – 17th/18th October (for downloads), and on December update CD’s.Volume Licensing – 1st week of NovemberRetail – 1st week of December

:,,)

Categories
ASP.NET Software Engineering

ASP.NET “Page Not Found” when pages exist…

I hit a strange problem today when I started getting the ASP.NET 404 error page whenever I tried to access my ASP.NET pages through IIS – whilst any non-ASP.NET pages in the same directory worked fine. After a bit of digging, it turned out that this was caused by me fiddling with the site’s “home directory” in IIS – I’d … Read more “ASP.NET “Page Not Found” when pages exist…”

Categories
ASP.NET Software Engineering

Dynamically loading ASP.NET 2.0 “Bindable” templates

Update: See http://weblogs.asp.net/james_crowley/archive/2005/09/06/424539.aspx

Just found out that ASP.NET 2.0 doesn’t support dynamically loading “bindable” templates from a file; you’re restricted to writing them inline. In other words, if you’re using a FormView or DetailView control, and plan to use the new two-way data binding features, any use of LoadTemplate is out of the window. Plus the BindableTemplateBuilder (for creating a … Read more “Dynamically loading ASP.NET 2.0 “Bindable” templates”

Categories
C# Software Engineering

Converting VB.NET code to C# (and back again) – V2

I’ve just updated the VB.NET -> C# and C# -> VB.NET code converter on Developer Fusion – a large number of bugs have now been squished! Check them out at http://www.developerfusion.com/utilities/

The utility uses the conversion code from the #develop IDE, and any bugs we come across I’ll be fixing and integrating into the #develop code too. Let me know … Read more “Converting VB.NET code to C# (and back again) – V2”

Categories
IIS Software Engineering

Permanent 301 Redirect with QueryString in IIS

If anyone’s ever tried to move domain, you’ll know its a pain. One way to make things a little easier is to provide an automatic 301 redirect from your old domain to your new one – this marks the new destination as a permanent change, and will generally be picked up by search engines.

IIS provides an easy way to … Read more “Permanent 301 Redirect with QueryString in IIS”