How to convert a .htaccess file for use in your Web.Config file on Windows Server

 If you're running a Windows Server and you have to run PHP websites on it chances are that you will be asked to apply rules from a .htaccess file to one of the websites on your server. Windows Server does not use .htaccess files. These usually come from Apache servers. However, Windows Servers use a similar file called the Web.Config file located at the root of all your websites hosted on your Windows Server.

You'll be glad to know that there is a converter built into IIS 7 that will convert any .htaccess rules into the format required for the Web.Config file. To convert your .htaccess file simply follow these instructions:

  1. Log onto your server and open IIS.
  2. Double click on the 'URL Rewrite' icon from the list under 'IIS'.
  3. Click on 'Import Rules...' from the right side bar.
  4. Copy the htaccess contents supplied to you and paste them into the 'Rewrite Rules' text box. Once pasted you should notice the 'Converted Rules' area will update. If you click on the XML tab you will see the Web.Config format of the rule entered.
  5. Ensure you're looking at the Tree tab and right click on the 'rule name' tag in the Tree View and click on 'Rename' to rename the rule to something other than 'Imported Rule 1' so it will make more sense to anyone looking at the web.config file later on.
  6. Click on 'Apply' from the right side bar and your rule will be added to your web.config file.

That's it. You're all done! Nice and easy.

The dreaded Server Application Unavailable IIS error

Server Application Unavailable

Is there any error more annoying in .net web development? I hate this error because it's so unhelpful. I actually got this error today and it took me a while to track down what the issue was thanks to that rubbish error message being returned to me.

One of the guys inside in work setup the project for me for a new website but never changed the .net settings from the default asp.net 2 runtime to the asp.net 4 runtime. "No problem" I thought and I quickly updated the runtime from .net 2 to .net 4 using my handy command.

I double checked IIS6 and confirmed that the new runtime was in effect. However, every time I tried to load the website I was seeing the 'Server Application Unavailable' error message. I checked the Event logs and nothing was mentioned in there so that was no help. I double checked all the settings and everything seemed correct.

Then it hit me. I had updated the framework but not refreshed the application pool for this website. Sure enough, once I refreshed the application pool the site came to life. I just wish IIS had some better error messages to help work around these situations. A simple prompt telling me that the application pool runtime wasn't matching the website runtime would have pointed me in the right direction.

Ah well, at least I know in future it this happens again :)

How to store additional details in your web session cookie

If you're using the ASP.NET membership you're probably aware that one of the things it usesto keep the user logged in can be a cookie. This cookie can be used to store additional details also to help you cut down on the database calls required for simple things like the user's name or email address.

You could write your own extension to handle the cookie creation and management but you might find it easier to use a third party library called FormsAuthenticationExtensions

This extension can be installed using Nuget: Install-Package FormsAuthenticationExtensions

Once installed you can use it very easily by adding the following code to your application where the user's is being logged in:

using FormsAuthenticationExtensions;

public bool Login(string userName, string password)
		{
            // handle your own logic to check the username and password and log in the user

            // if the login is successful, store some additional details into the session ticket
            if (User.Identity.IsAuthenticated)
            {
                var user = // make a database call to get this user's name and email address

                var ticketData = new NameValueCollection
                {
                    { "firstname", user.Firstname },
                    { "surname", user.Surname },
                    { "email", user.Email }
                };
                new FormsAuthentication().SetAuthCookie(userName, true, ticketData);
            }

            return loggedIn;
		}

As you can see the above code will take the user's email and name and store it along with the session cookie.

To read the values from the cookie in your MVC controller you can use something like this:

using FormsAuthenticationExtensions;

public ActionResult MyContactDetails()
        {
            // get the email from cookie
            var ticketData = ((FormsIdentity)User.Identity).Ticket.GetStructuredUserData();
            var emailFromCookie = ticketData["id"];

            return View();
        }

Or if you want to display the cookie details in your razor view you can do this:

@using FormsAuthenticationExtensions;
@{
    var ticketData = ((FormsIdentity)User.Identity).Ticket.GetStructuredUserData();
}

email : @ticketData["email"] 

Finally, if you need to update any of the details in the cookie (for example, if the user updates their email address) you can simply do something like this:

using FormsAuthenticationExtensions;

[HttpPost]
        public ActionResult MyContactDetails(ViewModel model)
        {
            // check cookie for data
            var ticketData = ((FormsIdentity)User.Identity).Ticket.GetStructuredUserData();

            if (ModelState.IsValid)
            {
                // update some of the cookie information with the new data
                ticketData = new NameValueCollection
                {
                    { "firstname", model.Firstname },
                    { "surname", model.Surname },
                    { "email", model.Email }
                };
                new FormsAuthentication().SetAuthCookie(model.Email, true, ticketData);

                return RedirectToAction("MyContactDetailsSuccess");
            }

            return View(model);
        }

As you can see it's very easy to use and a great way of storing small data in your app to help cut down on database calls. You need to be a little careful with this and ensure that you only store the bare minimum of information here. Cookies can't be too large so if you have anything more than 3-5 additional string data types and you might want to look at using a Session value instead. You should also avoid storing any complex data types in your cookies.

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!

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.

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.

How to transfer a domain away from GoDaddy.com

I've used GoDaddy.com for a number of years but recently noticed that their pricing was not as good as some of the competition. I also had my domains "protected" by DomainsByProxy.com which meant that I was locked into paying an extra $8.99 per domain for the privilege of having my whois details hidden.

Recently I decided that enough was enough and that I wanted to move my domains. A simple enough job you might think. Well, just like everything with GoDaddy.com things weren't quiet as easy as they should have been.

The first issue I had was to do with the DomainsByProxy.com. I could not remember my login details at all. I didn't have the username or the password to login. So, how do you turn off domainbyproxy.com when you don't know the account information? The following steps will guide you through this process:

NOTE: You must ensure that you have access to the email account used to register your domain. GoDaddy.com and DomainsByProxy.com will both send notifications, logins, domain transfer codes, etc all to this account so make sure you have access to the email before you start!

 

  • Head over to DomainsByProxy.com and click on "My Account" on the top nav bar.
  • Next, click on "Forgot Your Password".
  • First you'll want to get your customer number so click on "Retrieve customer number" and enter your domain name along with the little code underneath. An email will be sent to your email account registered for this domain. This can take up to 10mins to arrive so don't worry if you don't get it straight away.
  • Now that you have your customer number you can retrieve the password for the account. Go back to DomainsByProxy.com and click on "My Account" again. Click on "Reset Password". Enter in the customer number that you were just sent along with the email address used to register with DomainsByProxy.com. Wait a few minutes and you should receive an email with a link to reset your DomainsByProxy.com password. Click on the link (it only lasts for 2hrs so make sure you do it by then) and change you password to something you will remember.
  • Now that you have your username and password, you can log into your DomainsByProxy.com account and turn it off for your domain. Once this is turned off you can continue with your domain transfer.

 

Turning off the DomainsByProxy.com is vital if you are to transfer your domain as without it your new registrar will not be able to verify your account details and your transfer will fail. Next up you need to unlock your domain for transfer and request the authorization code for transfer.

  • Go to GoDaddy.com and click on "My Account" to log into your account.
  • Click on Domain Manager from the left hand side menu.
  • Next, click on the domain you wish to transfer.
  • There should be an option called "Locked". Click on the "Manage" link and a popup will appear with a checkbox checked. Untick this box and click on the OK button to unlock your domain. You should see a success message. This process can take a few mins for GoDaddy.com to process so go make a cup of tea before continuing as the system won't let you do anything else while it's waiting to unlock your domain. You will know once your domain is unlocked as the little padlock symbol on the domain listing will be shaded on your domain. GoDaddy.com will also email you to let you know.
  • Once your domain is unlocked, go back to the Domain Manager and click on your domain for transfer. Now go to the "Authorization Code" and click on the "Send By Email" option. This will email you the transfer code required for moving your domain to another registrar.

You are nearly there! Your final step is to actually move the domain to your new registrar. The next few steps are dependent on the registrar you are moving to but typically you would enter in your domain and either click on Renew My Domain or Transfer My Domain from their site. You will be asked for your authorization/transfer code which you can enter and then continue on to pay for your domain. Domain transfers should be free and you should only have to pay for the extra year you purchase for your domain.

Hopefully some of you will find this guide useful.

Top tips on how to be successful with your new website

Over the last few months of this year we've seen a lot of new customers come to us who want their first website. The customers are always great to deal with as there is nothing more exciting that delivering a site to them and seeing their eyes light up when they see their vision become reality. However, one thing I see happen time and again with these customers is that they fail to realise that a website is something that requires constant love and attention. For this reason I'm putting together my list of top tips for people who might be in the same boat and who are looking for advice on how to keep their site relevant after 6 months of taking ownership of their new site.

This guide isn't for regular internet designers or developers but people who might never have owned a website before. These points are all common sense to people who work in the industry but for someone starting out you'd be surprised how many of these points get overlooked. A lot of these points are also just good business tips. This is also a nice follow on guide to my tips for running an online store that I posted in the middle of last year.

Don't expect to get rich overnight - This is one of the most common problems I see. People expect to be "Internet millionaires" as soon as their new website or online store launches only to find that 'Hey, this thing requires a lot of work to get off the ground'. One thing I always tell them is that if this was a get rich quick scheme I'd be loaded by now but unfortunately it's not. Like any new business, it requires a lot of hard work, late nights, and constant marketing to get a new website noticed.

Update your content regularly - You can spend thousands on marketing your website, get the most expensive designer to create a beautiful theme for your store or go to every 'How to run your website' conference going but unless you keep your site fresh by updating the content regularly then people just won't come back.

Answer emails or phone calls from users of your site - New business owners are often a little shy starting off. It's OK, it's natural. Being nervous at the start of your business career is expected but never ignore a phone call or an email from a user on your website. You never know what the user might want. They could be calling to offer you tons of money (doubtful) or just to check if you can deliver item X from your site by next Monday if they order today. No one expects you to work 24hr/7 days a week but even a quick 'Thanks, I'll follow up in the morning' mail would be ideal to let the user know that you got their mail and will be in touch when you get a chance.

Request feedback from your users - Always have a contact form on your site. I'm always amazed at the number of clients who don't want to receive any emails or calls from site users. Think of all the missed sales opportunities you would have without a phone. It's the same thing with a contact form. If you run an online store I would also strongly suggest you put up a contact number for people to call if they have any queries. It all helps add to the confidence for the end user that your website is a proper, legit organization.

Follow up on any enquires or sales queries - Never expect the customer to come back to you about a question they asked a few days ago. If a user asks you about a service you offer or a product for sale then follow up with the user after a week if you hear nothing from them. Never harass the user by sending 44 emails in 30mins. Just a simple one liner asking if they require any further assistance or if they have further questions is all you need to do here.

Do market your new site as best you can - Ok, I know. You've read this one a million times already on other blogs. You need a blog, a Facebook account and a Twitter account, blah blah blah. Unless you are someone who is going to keep site content up to date (see point 2 above) then be careful going down this route. Nothing stands out more than a dead twitter account with 5 posts from that week 12 months ago when you first set it up or from a blog on your site with only 3 posts. Dead social networking accounts are not marketing.

If you don't have loads to say then look into Google AdWords or something similar. Don't overlook tradition marketing mediums either. TV, radio and newspapers are still enjoyed by millions of people. Market your site where your customers will be. If you run a website about fishing then advertise in fishing magazines or local free ads if that's where your customer base will be. Be smart about your marketing and don't let the web designer force you into setting up expensive ad words or pointless online accounts.

Interact with your users - When you have a new website there is nothing harder than getting the name out there. Marketing can help when it's done right, as I've mentioned in the point above. Another option you can do is to offer competitions or polls for users to come to your site and give you feedback on. If you offer services then allow web users to avail of discounts if they make a booking online. If you run a store offer free post to all orders of a certain amount. It all helps make the user think they are getting a benefit for using your site.

Allow users to send links from your site to their friends - A good trick to do on a website is to allow the end user to send a link to the page they are viewing to their friend. Nothing gets your site noticed faster than word of mouth. Make it as easy as possible for end users to spread the word and you're nearly half way there.

Spend your money wisely - You've spent money getting your website or new online store made, you show it to some friends and family and then they come back to you and say 'love it but it's missing feature X'. I don't know how many times I see this with new website owners. They all fall into the same trap of thinking that they need to have this feature on their site for it to success. They're losing millions because it's not online. How could we all have overlooked such an obvious feature?! You can have as many whizz bang features as you want on your site, you can spend thousands building them but unless you have the business basics in place you're wasting your time. All the features in the world are not going to get your site noticed.

You need to focus on marketing and getting the name out there first. All the new super features can wait until version 2 of your site. Of course, no web designer or developer will tell you otherwise as we will happily take your hard earned cash if you want to spend it so keep asking yourself if you need this new feature or if you would just like to have it.

So there you have it. These points are just some little tips to help get you started on your web master journey. The key points are really just what any new business requires to make it - marketing, keep clients happy so they tell their friends and hard work keeping your site up to date with fresh content to encourage users to come back to you. Let me know in the comments if you think I've overlooked anything. If you're a new website owner why not let me know how you're getting on or if you have any tips for other new website owners out there?