RTE News Reader hits the Windows Marketplace

RTE News Reader App for Windows Phone

Over Christmas I decided to dip my toes into making a Windows Phone app for my Lumia 800. If there's one app that I was missing when I moved over to Windows Phone from iOS it was the RTE app. There was no official app so I went about making a quick little app to pull in their RSS feed and make readings the news stories a bit easier to consume on the phone.

I ran into issues straight away as the RTE feed does not support RSS 2.0 which a lot of the code samples out there seem to be using. Thankfully as I've been using Linq to XML so much in my job I did a little workaround to allow me take in the feed in the app. After that any other issues I had were just your basic 'getting to grips' issues. Funny things like finding out that Windows Phones can't support GIF images out of the box or that they only have 16bit displays so gradients look crappy caught me off guard as I coded up the app.

Thankfully I could work around these limitations. Making the app was a great learning experience and was actually surprisingly easy to do for a typical .net developer. If I have one complaint it would be that the App Hub website is a bit dodgy right now. This is the website you register your app on. The website is really slow and while they have implemented ajax calls for most operations, it can take upwards of 25secs to see any results with zero indication that anything is actually loading for the user.

Having said that, there is nothing sweeter than the satisfaction of thinking that there are people out there who are using your app (and hopefully enjoying it!). I have tons of new features I'd like to add to make the app a lot more useful for others. As soon as new updates are out I'll let you know here or on my Twitter feed.

I was also a little shocked that my app went to number 1 in the Irish News section and number 6 in the overall top free downloads for the Irish Marketplace! That's pretty sweet :)

RTE News Reader app for Windows Mobile is number 1 news app in Ireland

If you want to check out the app yourself, head on over to the Marketplace and give it a whirl! I respond to all emails sent through the app so don't be shy and get in touch. I don't mind if it's good or bad. If there's a feature you'd like and I can add to the app than I'll do it :)

Entity Framework v4.2 upgrade not working

This particular error caused me some headaches so I decided to blog about it in the hope that it'll help some other poor soul! I have a pretty standard MVC 3 project that uses Entity Framework Code First for handling the database side of things. I decided to update my project to ensure it was using the latest version of all of the packages in use on my project (ninject/entity framework/etc). This particular project was using Entity Framework v4.1, which I had previously updated using NuGet without any problems, so I decided to download and install the latest version from NuGet - ver 4.2.

The Problem:

I know after installing any new version of Entity Framework it's always wise to restart Visual Studio and do a clean rebuild of your project but when I went to run this project locally it threw up the following error:

 

Could not load file or assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

 

It was fairly obvious that my project was looking for the wrong version of EF but I couldn't tell why. I went looking for any hard coded mention of EFv4.1 but nothing was returned. Next I did some searching online but nothing seemed to match my particular error. I took a closer look at the detailed error log and noticed it was looking for the entityframework.dll file but was not finding it.

The Solution:

I took a look in the 'Packages' folder that NuGet installs the files to. I could see 2 Entity Framework folders. One folder was for the older v4.1 and one was for the new v4.2. I took a look inside the v4.2 folder  and could see the dll files in there so I knew the files had downloaded. Then I took a look in the v4.1 folder and noticed that the folder structure was different.

  • I went back into the v4.2 folder (Packages\EntityFramework.4.2.0.0\lib\) and could see a folder called 'net40' that contained the dll files.
  • I cut the 2 files out of there and placed them into the 'Packages\EntityFramework.4.2.0.0\lib' folder (up 1 folder level).
  • I went back into Visual Studio, did a rebuild and everything went back to work for me.

Reading back over this post I can't believe how easy and simple the fix was. Up until now NuGet had always worked so it never crossed my mind that it would have botched the update. Hopefully this solution will help you out if you see that dreaded error message. Fingers crossed NuGet won't do anything like that again to me.

Dec05

How to fix WebResource.axd JavaScript errors appearing when using asp.net routing

I had an issue with one of our asp.net 4.0 websites recently. The site was using web forms, routing and had .net validation controls in use. Everything worked great until I used the validation controls and discovered that I was getting 2 JavaScript errors on every page that used these controls.

I spent ages looking for a solution because I was looking for the wrong thing! I thought that the issue was to do with the .net runtime but it's actually to do with the routing side of things. What you need to do is tell .net to ignore the .axd files so that the JavaScript being referenced in the HTML will actually return a valid page.

Thankfully the fix couldn't be easier. In your global.asax file make sure you include an ignore rule for any axd files that your project might create. For example:

 

void Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup
        RegisterRoutes(RouteTable.Routes);
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.Ignore("{resource}.axd/{*pathInfo}");
        // your page routes here
    }

Use the new URL routing in WebForms ASP.NET 4.0

Setting up ASP.NET webforms to use ASP.NET 4.0s new native routing setup was really easy to do on a recent project I completed. There were only one or two gotcha's but once you know about them you won't have any problems setting routing up on your own projects.

For the tutorial below I will assume that you have asp.net 4.0 installed and that you have an ASP.NET webforms site or project already created. For this example I will create routing for a very simple site that has the following pages:

  • Default.aspx
  • News.aspx
  • NewsDetails.aspx (expects an ID value to be passed through to it)
  • error.aspx

We will setup our demo so that the above pages are routed to the following addresses:

  • /home
  • /news
  • /news/news title/news id
  • /error

Step 1: If not already created, setup a Global.asax page.

You can do this by right clicking on the name of your project in solution explorer and selecting Add New Item. Select Global Application Class from the list and leave the page called Global.asax and click Add.

Step 2: Adjust the code in the global.asax file so it looks a little like the example below:

void Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup
        RegisterRoutes(System.Web.Routing.RouteTable.Routes);
    }

    public static void RegisterRoutes(System.Web.Routing.RouteCollection routes)
    {
        routes.MapPageRoute("Error", "error", "~/error.aspx");
        routes.MapPageRoute("Home", "home", "~/default.aspx");
        routes.MapPageRoute("News", "news", "~/news.aspx");
        routes.MapPageRoute("NewsDetails", "news/{categoryname}/{categoryid}", "~/newsdetails.aspx");
        routes.MapPageRoute("defaultRoute", "{*value}", "~/error.aspx"); // wildcard mapping
    }

Step 3: On your aspx pages adjust your page links so that they are generated as follows for simple page links:

<a href="<%: Page.GetRouteUrl("Home", null)%>" title="Home">Home</a>

<a href="<%: Page.GetRouteUrl("News", null)%>" title="Home">Home</a>

The above code tells .net to look in the routing table in the Global.asax page to get the actual file for the location requested. The handy thing about using this GetRouteUrl class is that you are not hardcoding filenames into your links which can be handy later on if you need to change where links have to go. If you want to pass any querystring data, like we need to do for the news details page in our example, then you can setup the link like below:

<a href="<%: Page.GetRouteUrl("News", null)%>/<%# HttpUtility.UrlEncode(NewTitleValue)%>/<%# Eval("NewsID") %>">Read full article ...</a>

The link above is taking the News Title and News ID values and placing them into the link so that we can get the relevant info on the newsdetails.aspx page. We are URL encoding the title so that we can ensure the text used in the title will be a properly formatted link. If we didn't do this then spaces or special characters in the title would case the link to either fail or look horrible.

Step 4: how do you read in querystring values from your routing link?

I have setup a newsdetails.aspx page that looks for a News ID value to be passed to it so we can get the relevant details from the database. In the above examples you have created the link so that the ID value we need will be passed in the categoryid field name at the end of the link. Reading in this value on the newsdetails.aspx.cs page is as easy as:

string idValue = Page.RouteData.Values["categoryid"] as string;

Step 5: adjust the links to CSS, Images and JavaScript

At this point you have seen how to setup basic routing for your pages, how to pass through querystring and read them but there is one last step you need to do before you can be on your merry way. Your CSS paths, Image paths and JavaScript paths all need to be told where to get the files from now that you have routing setup.

When the user goes to "news/news title/news id" you will find that your images and css fail to load because the paths would be output in the html as "news/news title/news id/css" instead of "root level of your site/css". To get around this issue we can simply tell .net to map the files to the correct location no matter what url setup we have. All you need to do is something like this:

<%: Page.ResolveUrl("~/images/pic1.jpg")%>

<%: Page.ResolveUrl("~/css/styles.css")%>

Using the tilda (~) will tell .net to start at the root directory of your website.

Step 6: Some little things to watch out for!

Redirect the user if the URL they enter is incorrect.

You might have noticed that in the first step I had a line in there to handle wildcard mapping (routes.MapPageRoute("defaultRoute", "{*value}", "~/error.aspx");). This can be handy if you want to bring your users to a specific page on your site if they type in the wrong address. In this example, a mistyped URL would go to our error.aspx page but you could easily set this up to go to your homepage or anywhere else on your site.

Make sure your folder name does not contain a dot (.) in the name when running locally.

This one drove me a little nutty while testing locally until I found the issue. I kept getting a Page Cannot Be Found error message. It turns out that .net does not like it when a folder name has a dot in it when routing is enabled for some reason. I usually have my folders called 'domainname.com' which is what gave me the error. Renaming the folder to 'domainnamecom' sorted out this weird issue.

There you have it. A nice simple example that covers most of the basics to get you up and running asp.net 4.0 routing on your new webforms website.

Hertz4Ryanair.com get's a new update offering even more choice for customers

Hertz4Ryanair.com is relaunching in over 26 countries very soon

I've been extremely busy the past few months working on a new version of Hertz4Ryanair.com that will be rolling out to all European countries very soon. This new version of the website includes many new additions including:

  • New Hertz Advantage branded area
  • Dual Hertz/Advantage pricing screen
  • Updated languages for Spanish, Portuguese, French, Italian, Dutch and Swedish
  • Improved admin area with charting controls, export to excel options, full control over when to display dual pricing, etc.

I'm also very excited about this project because it is the first project that I've worked on which sits on multiple servers for both the web servers and database servers. The raw power of the server setup is huge and I am very curious to see how it handles all of the traffic from launching in 26 countries.

The work never stops though and once this project is finished and live there are some new exciting changes coming to our online store software that will be launching in the early part of next year for customers so stay tuned!

Simple Resx Editor - A good alternative to using Visual Studio for Resx / Resource Files

Simple Resx Editor

I've noticed that some members of my team were having difficulties with Visual Studio when using resource files. Any time they would open a file it would crash Visual Studio. As you can imagine this was very frustrating for all involved.

After a quick search I found a pretty neat alterative editor called 'Simple Resx Editor' by Matías. Currently this resource editor is at version 0.6.2 but it is being worked on at the time to improve the functions available.

The main benefit I like about this editor is that you can open all your resource files, side by side and edit them all in one quick go. This is a perfect setup when dealing with multiple languages as it really speeds things up. If you just want to work on one resource file and you need to know what the Key Name values are simply click on the big Key icon on the top of the app. This little app is small, quick to use and really offers a benefit over the built in editor in Visual Studio in my opinion.

The only snag I noticed while working with the editor is that if you had a very long Value field there are no scrollbars showing. I've left a message to Matías about this issue and I'm sure this will be fixed in the next version of this software.

Book a taxi online using GlobalTaxiNetworks.com

GlobalTaxiNetworks.com has finally launched! Now any business can book a taxi, know how much it's going to cost in advance, save favourite journeys, re-book previous journey's, add via routes and even print off invoices all in the click of a button....ok it's a few clicks but it's still a slick system if I say so myself :D

Using the power of Google maps with help from jQuery, C# and Linq to SQL we're able to work out rates for your journey anywhere in Ireland. This system has been built with multiple markets in mind and we're hoping to help roll out the system for Tiománaí Services Ltd (the site system owners) into the UK, western Europe and further over the next 12months.

Initially when I started building the system I wasn't sure if it could be done but from trial and error - and countless late nights! - the site is finally up and running. I have to say that it's been one of the best projects I've worked on while at Dragnet Systems. It's also one of the first systems powered by our newest admin tool technology. The owners of this new system can look after any aspect of this complex system with ease. Everything from approving users who sign up, setting pricing and saving locations on Google maps can all be easily added/updated/deleted in a matter of seconds. As with everything we develop we have ensures that the admin tools get as much love as the front end of the website itself.

I'm really excited by the possibilities this site brings to the market and I'd like to wish everyone in Tiománaí Services Ltd all the best with the site going forward!

Dragnet Systems launches VGWines.com

Vanilla Grape Wines goes live using dragnet systems online store software

It's a new year and thankfully the work inside in Dragnet Systems shows no signs of slowing down. VGWines.com is a brand new online store for an existing wine retailer based in Kerry, Vanilla Grape Wines Ltd.

The store uses Dragnet Systems own online store software. We have rebuilt the front end engine to make it easier for our in-house designers to build templates for any new stores going forward. It will also help increase the speed at which we can build new stores for clients now which is fantastic news.

It was interesting to note that due to legal issues with selling alcohol online VGWines.com can only sell to Irish consumers. This is the first time one of our stores has been faced with such a restriction but it makes sense. As always Rebecca has done a fantastic job with the design of the site and it definitely has a perfect 'wine' mood about it. I'm getting thirsty just looking at it :)

How to read from and write to the web.config file using C#

To read from a Web.Config file using C# is very easy to do. Let's say we have an appSettings tag in our Web.Config that holds the website title. Inside in our web.config you would have something like this:


   

To get .net to read this value all you need to do is add this to your code behind page on your site. Be sure to add the System.Web.Configuration namespace as this is not added by default.

using System.Web.Configuration;

//read in the SiteName tag from web.config
string MySiteName = WebConfigurationManager.AppSettings["SiteName"];
If you want more details on how to read from web.config please see my earlier post here

You might also want to write to your web.config file to allow the end user to update this data. To do this you must ensure that the Network Service user (or the ASP.NET user on WinServer 03 or earlier) has modify permissions on your website root folder.

Without the correct permission you will get the following error if you try to add the code below:
An error occurred loading a configuration file: Access to the path 'c:\inetpub\wwwroot\yourwebsitefolder\py39wsfg.tmp' is denied.

Assuming you have setup the correct permissions this code below will allow your web app to write to the web.config file.

//update the SiteName tag in web.config with a new value
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
config.AppSettings.Settings["SiteName"].Value = "New Site Name Value";
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");

Dec16

How to use a JQuery UI modal box with asp.net

View Demo | Download Source

I was recently asked to look into making a JQuery UI dialog box (aka a modal box) work with asp.net. I thought it would be straight forward but as with anything in asp.net it turned out to be a little bit trickier than I had initially thought. Part of the problem was that I wanted to put the dialog box on an asp.net submit button and depending on the user's choice either submit the page or cancel the action.

Thankfully I stumbled across this great article over at DeviantPoint. It was pretty much exactly what I needed. However, for my example I needed to only show the dialog box if any of the checkboxes on the screen were not selected. In other words a normal postback would occur if every check was selected but if there were any checkboxes not selected the user would be asked to confirm their action.

If you take a look at my very basic demo page you will see exactly what I'm talking about. You will find all of the code within the source files I have posted for download but below is a brief overview of what is going on.

View Demo | Download Source

HTML used:


    
    
    

This is a top class widget. Features include...

Below are the required items for this product to function correctly:
Required Item 1 Required Item 2
Required Item 3 Required Item 4

Javascript used:


C# Codebehind:

if (!Page.IsPostBack)
        {
            //this line is used to hold the exact postback function call used by the asp.net button
            this.MsgBoxContinue.Value = Page.ClientScript.GetPostBackEventReference(AddToBasket, string.Empty);

            //ensure the postback message is blank on load
            PostBackMsgTest.Text = ""; 
        }

        if (Page.IsPostBack)
        {
            PostBackMsgTest.Text = "Content posted back successfully.";
        }