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
    }

NETGEAR WNDR3700 dropping wifi issues using Eircom broadband modem

[Feb 14, 2011] No soon had I posted about having wonderful hassle free internet then the blasted thing gave me all sorts of trouble again! This time I have a solution but you're not going to like it :) I bought a second hand netgear adsl2+ modem to use instead of the Eircom router. I noticed on the eircom router that it was dropping access to the attached Netgear router. I reckon I had a dodgy unit as using this new netgear router is amazing. No dropped wifi. No issues loading pages. Just smooth fast broadband! For those wondering about setting up a different router on Eircom you will need to use the User: eircom and Password: broadband1 to access the service. Most modern routers will auto detect all the other techno bits. Phew, it's been a long journey but it's definitely worth it.

[Jan 29, 2011] Ok, finally got this working! I now have DoS protection and SIP ALG back on but QoS still off. My MTU size is set to 1453 and, most importantly, I turned the firewall off on my ISP router as this was giving me hassle when in use with this Netgear router. Everything is now working great. Hopefully this post will help others who end up having problems with this router and their wifi dropping!

[Jan 25, 2001] Looks like I'm still having problems with the router dropping my wifi. I have turned off QoS options and DoS protection along with disabling SIP ALG. Hopefully this will do the trick as I'm running out of options to turn off! The router might be fast but it's useless if it keeps dropping the signal with zero feedback as to why :(

I recently purchased a new dual band Netgear wndr3700 for my house as I wanted something with a bit more oompf than the standard telecom company router (a company called Eircom). The main reason I picked up this new router was that I didn't want slower, older, wireless b/g devices slowing down my wireless n devices which I was using more and more for streaming to my tv.

For the first few weeks everything was ok but as I started to use this router more I noticed that web pages would randomly fail to load for me. It quickly became a huge irritation as browsing the web became a huge chore!

After reading up on the Netgear forums I noticed that a lot of other people were having this issue also. Thankfully the suggestions there helped fix my problem.

So, what did I do? It was all down to the MTU (Maximum Transmit Unit) setting on my Netgear router. By default the router had set this value to 1500 but anything above 1492 would cause massive drop outs with my modem. Setting the value to 1492 has worked a charm for me and if you have a similar issue I would recommend you try this quick trick to get things working smoothly again.

I did come across a pretty good tool called TCP Optimizer that would allow you test your maximum MTU setting for your modem. You can download the file from http://www.speedguide.net/downloads.php.

HTML5 and CSS3 round up for February on Stuff4Designers.com

showcase of latest html5 and css3 demos on stuff4designers.com

Just a quick note to say that I have a new post up on stuff4designers.com featuring a round up of some great HTML5 and CSS3 examples for February 2011. If you want to checkout what other people are getting up to with this new tech go check it out.

If you're working on your own cool HTML5 or CSS3 demo please let me know and I'll include you in next months post.

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.

Stuff4Designers.com is now live and ready to inspire you

I've been really busy over the last few months planning some really cool new projects that I'd like to launch during the year. As a side effect my own blog hasn't been updated as much as I'd have liked. Fear not though as I have some new posts that I'm currently working on that should be online shortly (fingers crossed!).

One new side project I have just launched is Stuff4Designers.com, a website dedicated to bringing you the best web resources and inspiration for web designers from around the interwebs. Rebecca FitzGerald-Smith is co-owner with me on this site.

Go check it out and if you have any design ideas or showcases be sure to let us know!

BlogEngine 2.0 theme is now online

Just a quick note to let you know that my CoolBlue theme is now BlogEngine 2.0 compatible. Head on over to the original post to download this file. This theme plays nice with Disqus if you want to use that commenting system and will work with the new login page links out of the box.

I have also included a BlogEngine 1.6 version of the theme if anyone wants to continue using the older version of BlogEngine.

I should have a new theme available for BlogEngine 2.0 in a few weeks. If you come across a nice looking free HTML template that you would like me to convert to BlogEngine please let me know in the comments below.

I just updated my own blog to run the new BlogEngine and it was pretty painless to setup. The only snag is that I'm using Disqus as my commenting system so I've lost all my older comments because I'm using this new system. It's a small price to pay as personally I think Disqus is a better comment system.

JouJouJewels.com handmade and designer pearl jewellery site launches

JouJouJewels.com website launches. Lovingly handmade jewellery for sale worldwide.

Well it's been a long time coming but JouJouJewels.com has finally launched! For the past two years my über talented girlfriend, Rebecca FitzGerald Smith, has been busy sourcing and making handmade pearl jewellery. Last Christmas she was selling to friends and families but this year she wanted to go all out and setup an online store.

Rebecca works with me in Dragnet Systems and even though we make online stores for a living it was interesting to see how much work and effort goes into making a store when it's for yourself. To say that you can be your own worst critic would be an understatement! Rebecca has poured her heart and soul into this project and I think the end results are outstanding.

Everything from the website design to the store technology was handled by Rebecca. Attention to detail was given to everything on the site, from the logo down to the little basket icons. I know I'm going to be biased when I say that it is a fantastic website but I'm really proud of all her hard work and just wanted to wish her all the best with this new venture.

With Christmas just around the corner perhaps you could find the perfect gift over on the store for someone you know. Even though shipping on the site is for UK and Ireland initially, JouJouJewels.com will ship worldwide upon request.

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!

CoolBlue - A brand new BlogEngine Theme

a brand new blogengine.net theme by Richard Reddy

I really like BlogEngine.net but I've found it frustrating to get some really nice modern themes for it. There are a good few examples out there and I've blogged before on where to go to get some good themes but unfortunately the vast majority of themes look dated by today's standards.

Instead to just complaining about it, I've decided to convert some nice modern free html themes that are out there over to the BlogEngine platform. I found a really nice site called StyleShout.com that's run by Erwin Aligam. He has some really nice html themes that he has given away for free so I got in touch with him recently to find out if I could convert these themes over to blogengine.net. Thankfully, he was more than happy to let me go off and destroy, er, I mean convert his themes! ;)

The first theme that I have converted is called CoolBlue. I really like the clean and simple look of this theme. To set this theme up on your own BlogEngine couldn't be easier.

  • Download the file at the end of this post and unzip it to your blogengine Themes folder.
  • Before you upload the theme you will want to change some links on the site.master page (footer section) within the template folder. I have left the Contact Info section in the footer so you can put in your own Facebook or Twitter links. If you would rather display another Widget simply remove the <div class="col"> tag and its contents. Now that you've configured the theme with your own links, upload it to your themes folder online.
  • Log into your website and go to Settings in the admin section. Change the Theme to CoolBlue and click on Save Settings. The Preview option won't work as the stylesheet is within a CSS folder and not on the root level. The theme will work on the 'Live' website so don't worry if you view with Preview and it's missing some images. [Update: This issue has now been resolved.]
  • While still logged in, go to the homepage of your website. You should see the new theme looking all shiny on your site. We're nearly there now with the tweaks.
  • There are 2 Widget areas for you to add your BlogEngine widgets. The side widget and the footer widget. Simply select the widgets you want to use to get them to appear in the relevant area. Please note that I have not styled up every widget so some css tweaking may be required for some of the more unusual widgets that you might want to display. For the footer widgets, you should really only show 2 widgets if you plan on keeping the Contact Info column. If you display anymore widgets it won't look pretty - you have been warned!

So that's it. Not too much tweaking - mainly just putting in your own twitter and facebook links.

This is the first theme I have converted. I will do my best to make one a month as long as I have some nice html templates to work with. We will see how long that plan lasts for! Till then, enjoy and let me know what you think.

[08 Nov 2010 Update] I have now updated the css styles for the comments area. This fixes the padding issue with smilies and patches up replies indenting.

[24 Nov 2010 Update] I have updated the css and files to be BlogEngine 2.0 compatible. There are some differences between BlogEngine 2.0 and 1.6 so make sure you download the correct file for your blog engine.

BlogEngine 2.0+ use this file: CoolBlue_BlogEngine_2.0_24Nov2010.zip (94.72 kb)

BlogEngine 1.6 use this file: CoolBlue_BlogEngine_1.6_24Nov2010.zip (94.62 kb)

Created a new logo for the UrbanSpaceInitiative.com website

A good friend of mine recently setup a new website, urbanspaceinitiative.com, that discusses the connection that exists between urban public space and the life of urbanites through the lens of  geographical imagination, urban design, art  and urban  culture. My friend was looking for a simple logo to help jazz up his site a little. I created the image above using Adobe Fireworks and, thankfully, he was pretty chuffed with how it turned out and it's now live on his website :)

I'd encourage anyone interested in public space imagery to head on over to his site. He has some beautiful imagery on the site and his articles go into great depth on the subject of public spaces.