MCTS 70-515 Web Applications Development with .NET 4 - In Review

0 comments
Recently I studied and sat a Microsoft Certification for ASP.Net 4.0 and MVC. As much as some people on the web cause grief to anyone who’s interested in certifications I must state that I actually did learn a lot about other parts of the framework that day-to-day I never touch. The great thing about this experience was that while yes I did learnt about some parts of the ASP.Net framework that I’ll never touch because in the real world you wouldn’t use them, I also found I learnt about a number of other parts of the framework that I didn’t know were there and these new bits of knowledge will help me daily.

Adding filters to your ELMAH installation

2 comments
One of the most common configurations people use when setting up ELMAH is email exception logging so that you get notified whenever “shit’s goin’ down” on your site. This leads to a follow on issue that stems from this in that you end up receiving 100’s of emails a couple of times a week as your website gets scanned by evil doers looking for vulnerabilities – but there is a simple and elegant solution.

Build Accessible web sites with Visual Studio – WCAG reporting

0 comments
Adding Accessibility to a website for access by sight or hearing impaired users is a thought that many developers have post build. Along with this, when you’re tasked with the job of building an accessible website, Visual Studio probably wouldn’t initially be a tool that comes to mind, but Visual Studio has everyone fooled on this topic as it has this functionality covered, you just need to look a little below the surface.

Writing your own custom ASP.Net MVC [Authorize] attributes

1 comments
ASP.Net’s [Authorize] attribute is another cool feature that makes it easy to add authentication at the Controller level when building a website, but the real goldmine here is that like nearly everything else in ASP.Net MVC, you can pick apart the functionality and extend it yourself – In this post we will take a look at creating our own custom Authentication attribute.

An Exercise In The Finer Points Of ASP.Net MVC 3 Model Aware Data Annotations

7 comments
Anyone who asks me will know that i love the simplicity and elegance of creating ASP.Net MVC’s custom data annotations when writing your own validation in ASP.Net MVC. One situation that can be a tricky one to dig yourself out of when coming to more advanced validation logic is writing custom validation attributes that can see/compare properties between itself and other model properties.

ASP.Net WebForms – Partial Page Caching With The Substitution Control

1 comments
Often when using built-in ASP.Net WebForm Caching to speed up a page’s output time, people feel pigeon holed into either caching the whole page, or setting up output caching for the majority of controls on the page individually. An often overlooked approach is to use the Subsitution control. This allows you to have your cake and eat it too by caching the whole page, and yet still updating a part of the page on every load.

Replacing query string elements in c# .Net and JavaScript

1 comments
While writing list navigation and search features in websites today there is a constant need to find/replace and play with query string elements, so that you can easily manipulate these mystical items while you’re carrying them around in your website’s URLs. I have a few little methods I’ve used over the years and carry with me project to project, and this post is putting them on the record for easy access later.

ASP.Net HttpModule to detect and redirect mobile devices version 2.0

0 comments
Last year I wrote a post on how to setup an ASP.Net HttpModule that detects and redirects mobile devices so that you can show a different version of your site to users browsing your site using whatever hot new mobile device is going around. Since then the lay of the land has changed a bit, so i thought it was time to reassess the solution i recommended and offer you a new updated one for 2011. The great thing about this solution is it’s a lot more future proof, so hopefully i won’t have to write another blog post next year.

Required CheckBox validation in ASP.Net MVC 2 onwards

6 comments
Having forms with checkboxes that require users to check them to be valid is a pretty common phenomenon on the internet today, however when thinking about this in terms of ASP.Net MVC it can not always be obvious what the best approach to take is. Thankfully the ASP.Net MVC team gave us the support to create a really simple solution when they added inheritable validation classes to the framework.

GaDotNet has moved to CodePlex

0 comments
Last year i started on a project that allows easy tracking of page views, events and transactions to your Google Analytics account without using JavaScript or a Browser simply using a .Net wrapper. This became GaDotNet. Over the Past 6 months i have had well over 2,000 downloads and many thank you emails so obviously people are finding a use for my code – this can only be a good thing. Now it is time for the project to grow up – so I've moved it to a remotely hosted source repository – CodePlex.

Facebook Apps in 10 mins using Microsoft Facebook SDK

7 comments
So It’s been about a year or so since I've written any Facebook applications for clients, and in that time quite a lot has changed in the space. There are quite a list of available libraries you can use to write Facebook applications in .Net with, so it can be sometime daunting to pick one as your favourite. This can be further complicated by the fact that for a lot of people, when they first go to write a Facebook application some of the jargon thrown around can be confusing when you know nothing about the Facebook API – what approach should you take? does having ASP.Net MVC or Silverlight support make the library a good one?

Release of Google Analytics Dot Net

7 comments
So today is the day that a little side project I've been working on sees the days of light. GoogleAnalyticsDotNet allows you to log a page view to Google Analytics from code behind of a website or from within a web service or win forms project without needing to use the Google JavaScript code, or even use web browser at all.

Automatic NTLM Logon for ASP.Net, TFS & SharePoint sites with IE & FireFox

0 comments
NTLM Authentication for websites is a great addition to the bat-belt when writing ASP.Net sites. Additionally it is also a great to have support for it in Team Foundation & SharePoint portals. However as great as having support for NTLM authentication may be, having to enter & re-enter your credentials when surfing Intranet or Extranet sites can be an annoyance that is just not worth it.

Automated deployments with TeamCity, Deployment projects & SVN

12 comments
One of the continually high risk and sometimes fiddly operations in web deployment is a web application’s deployment, and yet a lot of people working in smaller teams seem to have become stuck in the land of cowboys because the task of automated deployments seems either too difficult, too time consuming to setup or is perceived as un-needed. I’m about to attempt to prove all of these things wrong, while at the same time allowing you to get back to doing what you do best: write code.

Make your XML strongly-typed: Because you can, and its easy

2 comments
Earlier in the week i posted a Twitter post commenting on how if your not using the XMLSerializer class to you advantage, well, as Scott Hanselman puts it now and then: Your doing it wrong. I use the XML Serializer classes on a daily basis to refer to my XML in a strongly typed manner and often wonder why i see people go to so much effort in creating hard to maintain code just to get data from or send it to an XML file.

Keep your ASP.Net websites warm and fast 24/7

5 comments
ASP.Net web applications are awesome most of the time. But there is a sad reality: ASP.Net applications are tuned to handle huge amounts of traffic, not 50 page views a day. This becomes an issue when you have limited traffic to your site, because if your it doesn’t keep being viewed, your application pool may recycle, and that important visitor number 1 gets screwed waiting as your site rebuilds or your app pool to fires up. Whether it’s a SharePoint site, an ASP.Net or your internal TFS 2008/TFS 2010 Server, you want it to be FAST… all the time.

Video encoding in the cloud in mere minutes

0 comments
I’m currently involved in a new project for a client that involves a lot of user contributed video, that then gets viewed on the site. This means video encoding, and lots of it, and the budget and timeline involved mean that the client can’t afford to implement the dedicated hardware to do this themselves. Why not encode in the cloud you say? Why not.

Twitterify your strings using c# regex

3 comments
So you’ve set up a twitter feed on your site – sweet. Now all your peeps can see how excited you are about the new limited edition Whitney Houston EP you’ve been listening to. But then you post a link – or a reply to a fellow twitterati member and those handy auto links you’ve become so used to aren’t there. Bummer duuude – lets fix that.

How to use the Not-so-new MailSettingsSectionGroup

1 comments
Today i came across something that from my day-to-day coding i have noticed a lot of my fellow coders at work/play have let slide on their path to .Net Mecca – using the MailSettingsSectionGroup section of the web.config to specify both SMTP server host details as well as they other properties such as user/pass credentials in a central, single, easy to use manner. So I'll take this opportunity to make it as easy as possible for you to use.

Developer productivity is important - Reality or Myth?

0 comments
Today i was reading a post by Rob Conery in which he discussed both his thoughts on developer productivity in relation to the creation of a new OS project (ASP MVP), and how he may have thought that in some instances hiding behind WebForms and not touching MVC was really just laziness or ignorance mistaken for productivity. Additionally i also read another post by Scott Bellware in which talks about a similar subject, in that developer productivity when viewed in isolation, is really a myth.

C# Convert DataSet to CSV

0 comments
Today i found myself wanting to quickly export a dataset to CSV and i didn’t want to bloat of a library that does more than i need. The following method is the result of this need/want.

SubSonic, SQLite, Sonic.exe and 64bit, oh my!

1 comments
Well this week i started work on my new development machine – a 64bit Windows 7 machine mmmm tasty. Everything has run perfectly smoothly until i hit one weird little issue. While attempting to generate a new data layer for a SQLite database using Subsonic i received nothing but errors – Another simple fix which I'll show you in this post.

Retrieving a Flickr Photo ID from a URL using RegEx

0 comments
While working on a recent Flickr/Google Maps mashup i needed to make it as simple for users to share their Flickr photos as possible. What is easier than simply asking them to enter the Flickr photo page URL? Using this I'll show you a simple way to use RegEx to retrieve the photo ID part of the URL using c# as well as a JavaScript RegEx version for your ASP.Net RegEx validators. Lets get to it!

Consuming an ASP.Net WebService with Jquery & JSON

2 comments
ASP.Net Script Services and Web Services are an incredibly powerful tool for providing rich dynamic sites using AJAX. As good as they are, there are times when you want to access them in alternate ways. Combine JQuery, JSON and ASP.Net Web Services and you have a combination that rivals the A Team – lets take a look.

Consuming an ASP.Net WebService with Jquery & JSON

2 comments
ASP.Net Script Services and Web Services are an incredibly powerful tool for providing rich dynamic sites using AJAX. As good as they are, there are times when you want to access them in alternate ways. Combine JQuery, JSON and ASP.Net Web Services and you have a combination that rivals the A Team – lets take a look.

Adding Windows Live Writer support to your Blog engine

1 comments
If there is one blogging related tool that I've come across lately that i think has been a game changer it would have to be Windows Live Writer. However some people are using either a custom written blog engine (like me) or are using a blog engine that doesn’t support Live Writer. If that is the case i will show you a simple way to integrate Windows Live Writer support into you blog with WebServices and the MetaWebLog API.

Sending encrypted e-mail with C#

3 comments
There are times when the invention that we all call E-mail just doesn’t cut it for sending information securely. It is because of this that in every case where information really needs to be sent securely E-mail is not usually the medium chosen to send it. As most developers know though there are times when you have to bite the unsecure E-mail bullet. I’ll show you a way to solve this conundrum and at the same time probably keep your current e-mail client.

Forcing ASP.Net to use a Proxy to make requests

0 comments
This is a quick one today. I was recently working with a web application that runs a spider to index content on a bunch of intranet sites. The client was a large company with a very security conscious IT team, that had locked down all intranet access from the web server server in question. Luckily Dot Net supports proxies in a loving fashion, and I'll show you how.

Getting a full ASP.Net rendered page as a string

0 comments
So there i was looking for a simple solution to offer a preview function on a CMS for a client at work, when it hit me. Why try and replicate the content of the page in anyway (i could use a blank page and fill it in, i could carry values as a session and redirect to the front end view page. The reality is: I could do many different things. The real question comes down to “How would a Ninja do it”