Setting custom errors in asp.net

If you want more control over what is rendered when there’s a problem with your website, then you will need to set custom errors for any problems you foresee. Two common examples of this are “Page not found aka 404 error” and “Internal server error aka 500 errror”. The 404 err0r happens when a page that doesn’t exist is being requested while the 500 error happens when an error has not been properly trapped in your web application logic.

If you do not set custom error pages, default error pages for those errors will be displayed. There are not very nice looking albeit they convey the message to the more technical person and not the average user. So with custom error pages, you can have your own design which can be in line with your current theme or have something more sophisticated to show to the user and tell the latter what the problem is in very simple terms. However setting these custom error pages can be a problem if you do not understand how they are called.

There are 2 ways to achieve this. The first one relies on you trapping the error in your code and calling your error page. If for example, someone calls a page with an invalid PostId (a post id which does not exist in your database), you can fire off your own custom 404 page. Just remember that you need to do the following before setting the http response code to 404:

Response.TrySkipIisCustomErrors = true;

The second way to have custom error pages in asp.net is to set them in the web.config file. There’s a section under system.web for customErrors and here’s how you can use it:


<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/PageError.aspx">
 <error statusCode="404" redirect="~/PageNotFound.aspx"/>
 <error statusCode="500" redirect="~/PageError.aspx"/>
 </customErrors>

It is important to have a defaultRedirect set, otherwise IIS default error page will be shown for other statusCode that you have not defined.

You will also need to edit your web.config file and add the following to the system.webserver section:

<httpErrors errorMode="Custom">
 <remove statusCode="500" subStatusCode="-1"/>
 <error statusCode="500" path="/PageError.aspx" responseMode="ExecuteURL"/>
 <remove statusCode="404" subStatusCode="-1"/>
 <error statusCode="404" path="/PageNotFound.aspx" responseMode="ExecuteURL"/>
 </httpErrors>


customErrors vs httpErrors – What’ the difference?

For all requests which are served by asp.net, customErrors will be called. Any requests which are handled by IIS will be transferred to httpErrors. You can try it for yourself. If you have a folder which does not have a default document (eg default.aspx), then there will be an error. If you don’t have your httpErrors section defined, you won’t see your custom error page but the default IIS error page.

Remember to have the line Response.TrySkipIisCustomErrors = true in your error pages, otherwise IIS default documents might kick in.

Note that I’ve tested this on IIS7.5 and .net framework 4.0.

Google PR Update 27 July 2011

The long wait for a major Google PR update is now over as the PageRank has been refreshed today (27th July 2011). I’ve checked my sites (30+ I’ve got at the moment) and can confirm that it was not a minor update but a full scale one. Most of my sites have been an increase in PR but some of them dropped as well.

Backlinks is what PR is all about (seo mauritius is a good place to do that btw) and if you have been doing your link building well, then you would be happy today to see your PR going up the scale. If you haven’t though, there’s still time although you’ll have to wait a couple of months before seeing any result if you start your link building campaign today.

What I’d like to share today is that an expired domain which I purchased a few months back, dropped to PR N/A during 2 last updates but for this PR update that just happen, it went to PR4. Well it has many nice juicy links pointing towards it and it was about time anyway. On another expired domain (which is PR3) where I linked a new site, the latter jumped from PR0 to PR3. However there’s no real movement in terms of SERPs, so I believe expired domains do not count towards ranking but they will give you PR love, so all is not lost.

And another thing which I’d like to point out (maybe reminding myself as well) is that if you stop building links (as in acquiring new links to your site, then sooner or later, you will lose your PR and possibly your traffic. This happened on one site which has been PR3 for a couple of years now but because of neglect it has fallen to PR2 and the traffic is diminishing steadily on top of that. So it looks like I’ll be busy with more promotion and link building for this one now…

Using twiends.com to get more twitter followers and facebook likes

twiendsFacebook and twitter are 2 social networking sites which can increase the traffic to your website dramatically. However you need to have facebook fans and twitter followers first to benefit from them. So I started using twiends.com in an attempt to increase the number of twitter followers on my account as well as likes on my facebook fan page.

Twiends use the terminology “seeds” which is basically equivalent to points or money. The more you have, the better as it will enable you to get more followers. When someone follows you on twitter, your number of seeds decrease (mininum 2 seeds for each follower but you can increase that to 5 if you want to attract more people). When you join twiends, you get 15 seeds to start off with but if you complete your profile, you’ll get an additional 40 seeds.

So I had 55 seeds in my account and I decided to add my twitter page now. As soon as twitter was linked, I saw my seeds decreasing. In the space of a couple of minutes, I was down to 25 seeds. I checked my twitter profile and I saw I was getting new followers. However that was not what I wanted – I wanted twitter followers from a specific country so that it’s more targetted when I tweet. I searched quickly on twiends help page but had no luck. Google did not bring me any good results as well and within like 10 mins, I was at 0 seeds. This means that no one else would follow me as from now. I then performed another search to see how I could change my settings to get targetted followers and manage to find it. You have to click on Settings, then select Twitter from the left hand menu and edit your preferences. I specified the country I wanted to get followers from, gave 3 seeds for each follower, chose a Drop Rate of average and left the Membership Length at the recommended settings.

The Drop Rate is basically when someone follows you (you lose seeds because that person gets the seeds for it) and then stops following you after a short period of time. I’ve had a couple of people do that on my account. Out of 23, 7 stopped following me within an hour. So it’s a waste of seeds. The membership length should however be left at the recommended settings as new users are the ones who are more likely to follow you.

Since I had 0 seeds on my account, I couldn’t get more followers. I checked other free ways to get seeds and found out that if you join their newsletter, you will get 50 seeds. Referring other people to the site will get you 25 seeds if that person becomes a member that is. You can also buy seeds; for $30 you can get 1250 seeds.

With 50 seeds in my account and followers targetted to a specific country, I did not experience any bad/unwanted follower. Actually I did not get any followers at all because the country I’m targetting does not have many users at the moment. Anyway, let’s see what the future holds for twiends.

Working with subdomain on localhost

If you need to test sub domains on your development machine before deploying your web application, then you might be wondering how this can be done. Fortunately there’s an easy way to do this and all you have to do is add an entry in the hosts file for the subdomain.

Location of the hosts file : C:\Windows\System32\drivers\etc

Note that the hosts file does not have an extension and resides in the same location for Windows 7, Vista or XP.

You will need to open this hosts file in Notepad as an administrator, otherwise you wouldn’t be able to edit the file. Since all IP address starting with 127 belongs to localhost, you can therefore add a second entry in the hosts file for the subdomain that you want. An example is shown below:

127.0.0.1    localhost.com
127.0.0.2    test.localhost.com

Once the changes are saved, you will be able to browse to test.localhost.com. If you want to setup a website in IIS for that sub domain, then you will need to edit the bindings so that it listens to 127.0.0.2 on port 80.

How to do maintenance work on a live website?

When you first launch a website, you’re not too concerned whether the site is down or having problems because initially you have few or no visitors at all. So you’ll not be upsetting anyone if the website is down but that is a huge problem is your website is established and you need to perform updates or maintenance work to your site. People might be accessing your site and they could be put off if it does not respond properly or it shows errors.

Steps to follow to update a live website

  1. The first thing that you need to do is point the live website at a different directory (web app).
  2. Then you need to ftp your new files to the directory of your live site
  3. And lastly you’ll need to point the live site back to the original directory

This sounds really easy but there are things to take into consideration. While your site is down, your first priority is to inform your visitors that you’re performing maintenance work on the site. You could put up a page with a nice little message for that. What I’ve done is create a web app specifically for that purpose. It has an HttpModule that intercepts all incoming requests and redirects to a maintenance page. So no matter which webpage of my website people are trying to view during the maintenance period, they will be shown the maintenance page.

Now that’s all good but you need to inform search engine crawlers as well, otherwise they might think that your page does not exist or have been modified and that could result in either your pages being deindexed or dropped in rankings. To ensure that bots know your maintaining your website, you’ll need to respond with a 503 http status code. This informs them that the downtime is temporary and your site will be back up soon. In my case, this is handled in my httpmodule which issues the 503 status code.

Prevent IIS from showing a default error page

My maintenance web app was tested on my Windows 7 laptop and everything worked fine here but when I uploaded the site content to my server, my custom maintenance page did not show up and instead I was presented with an ugly default error page. The http status code was 503 (which is correct) but the page itself came from IIS and was not the one I designed. To solve this problem, I had to add Response.TrySkipIisCustomErrors = true in my httpmodule to prevent IIS from intercepting the request (http://www.west-wind.com/weblog/posts/745738.aspx). Here’s the code:

private void Application_BeginRequest(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;

context.Response.TrySkipIisCustomErrors = true;
context.Response.Status = "503 Service Unavailable";
context.Response.StatusCode = 503;
context.Server.Transfer("~/Maintenance.aspx", false);
}

The use of the app_offline.htm

When I first heard of app_offline.htm, I was really excited because it was such a painless way to go into maintenance mode. You just add this file in your website contents and bang, you are in maintenance mode. All calls are intercepted and the http status code becomes 503. You can put a nice little message in that html file for your visitors and design it beautifully. There are a couple of problems with this approach though:

  • First, your web app needs to be in a stable state. If your modifying dll in your bin or web.config, that’s all going to render your live website into an unstable application and app_offline.htm will be pretty much useless and your visitors or search crawlers will not be happy. I had this problem as my site is precompiled and changing one file means that the whole app needs to be rechanged. So in the end, I had to write the http module to overcome this problem.
  • Second, you cannot insert images in the app_offline.htm because relative paths will not work. The workaround is to have the image hosted on another server (maybe a free one) and have it embedded in the html (http://pbodev.wordpress.com/2009/12/20/app_offline-htm-with-an-image-yes-we-can/).
  • Third, you might need to have enough content in the html file (it needs to be a certain size) for it to display properly across all browsers. So if you have just a one line sentence, some people may be presented with an ugly default error document.

Maintenance work on a website is inevitable but as long as you have a process in place, everything should work out fine. Just remember to maintain your website when you have the least number of visitors.

DropDownList in ASP.NET does not retain control state

I’m not a huge fan of ViewState because I’m obsessed when it comes to page speed and ViewState just seems to cluster my webpage with sometimes unwanted info. So I tend to switch viewstate off and guess what, dropdownlist does not retain the selection the user has made before postback!

This, to me, is a serious design flaw within the Microsoft .Net framework because a DropDownList should retain its control state just like a checkbox and not rely on viewstate information being available. It happens that textboxes are able to save their control state even with ViewState off but not DropDownList. Why is that, I wonder?

Anyway, the workaround for this problem if you have turned off ViewState in your application is to request the selection the user has made from the dropdownlist through the request.form variables by passing in the ID of the select box as follows:


public static string GetSelectedValueFromDropDown(System.Web.UI.WebControls.DropDownList listBox)
 {
 return HttpContext.Current.Request[listBox.UniqueID];
 }

Hopefully Microsoft will fix that in a future release :)

Ajax file upload with JQuery

Working with AJAX makes websites more interactive as no postback is required but if you need to perform file uploads, then this can become very tricky. At the moment, the XMLHttpRequest object does not support sending files to the server. So real ajax file upload is not possible but there are a few hacks that gives the impression that file upload is being handled by the ajax framework. The most common way of faking ajax file upload is through the use of a hidden iframe. What happens is that the hidden iframe submits the multipart/form-data and the server sends the response back to the iframe. However it is easier to use a plugin of some sort instead of going into the intracacies of building something that someone else has already done.

Using ASP.NET HttpHandler for file uploads

Before I started doing ajax file upload, I used the ajax method of the JQuery’s library to fire off a request to an httphandler in asp.net but the context.Request.Files would always be zero. This meant that no files were being sent to the server and it gave me an index out of bound error. This is how I learnt that ajax does not currently handle files and I began to explore new ways to upload files through javascript.

There are many plugins available but I wanted something that most users will already have on their system. Most people already have javascript installed on their machines and working with that was a better option than having flash based upload plugins. My second requirement was that I needed something very lightweight that would only do the functionality that I need and not offer many more that I would not really use. So I ended up checking a plugin which is called Ajax File Upload.

AjaxFileUpload.js

This ajax file upload script (http://www.phpletter.com/Demo/AjaxFileUpload-Demo/) does exactly what I need but the lack of documentation has made me spent hours trying to figure out how it works. The first problem that I had with it was that my web app was going to send the uploaded file to an http handler which would send back json output confirming whether the upload was successful or not.


$("#btnUpload").click(function () {
 //var filename = $("#myfile").val();
 $.ajaxFileUpload({
 url: "/PostFileHandler.ashx",
 secureuri: false,
 fileElementId: 'myfile',
 dataType: 'json',
 success: function (data, status) {
 $("#result").html(data.msg);
 },
 error: function (data, status, e) {
 alert("My Custom Error: " + e);
 }
 });
 });

As you can see, I’m already telling the ajax file upload plugin that I’m expecting json output and in my http handler, I was outputting json by having context.Response.ContentType = “application/json” but that did not work and that’s how I spent literally hours trying to fix the problem. Everytime I tried uploading something, a dialog would pop up asking me to download a file from my http handler and when I inspected the content of that file, it had the json output in it. So the plugin was not handling the output correctly. The solution was to change the output response in the handler to context.Response.ContentType = “text/html” which made everything worked but is undoubtedly wrong.

The second problem is that if you try to upload anything greater than 4Mb, you will get the error XML tag name mismatch (expected hr) because the plugin can’t handle it. The solution is to check beforehand the size of the file the user is trying to upload but that ain’t possible with javascript/jquery and you’ll have to use something like flash to get this information.

I’m not sure whether I’ll be sticking to this ajax file upload pluging because of the security issue it poses. Ideally, you don’t want the file to be sent to your server if the size is too big and the reason for that is because it will eat your bandwidth, memory and will be stored in a temp folder on your drive (although it would be deleted afterwards). With flash based uploads, you can restrict what is sent to your server beforehand and prevent denial of service attacks (DoS) by preventing the workload from reaching your server scripts.

Dynamic controls, viewstate and postback

When using dynamic controls, many people will encounter all sorts of different problems that can take hours or days to solve. It is therefore essential to understand how asp.net handles events, postback and viewstate.

Dynamic control disappears on postback

If you have a user control which contains a text box, a literal control and a submit and you add the control programmatically, chances are that when the user control’s submit button is clicked, the user control will disappear instead of showing the value of the textbox in the literal. This happens because the user control (.ascx) is hosted by the page (.aspx) and the parent page does know of its existence unless you have used the declarative syntax in your markup. Here’s the html for  a page called Slave.aspx


<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.master" EnableViewState="true" CodeFile="Slave.aspx.cs" Inherits="Slave" %>
<%@ Register Src="~/FirstControl.ascx" TagName="FirstControl" TagPrefix="gis" %>
<%@ Reference Control="~/WebUserControl.ascx" %>
<asp:Content ID="content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<hr />
<h2>slave page</h2>
For the slave...
<gis:FirstControl ID="FirstControl" runat="server" />
<asp:HiddenField ID="hf" Value="0" runat="server" />
<asp:PlaceHolder ID="ControlHolder" runat="server" />
<hr />
</asp:Content>

<gis:FirstControl ID=”FirstControl” runat=”server” /> is the declarative syntax here but that’s not dynamic loading. FirstControl has a button and a checkbox and when the checkbox is checked and the submit button clicked, it will load dynamically another user control, in this case, WebUserControl.ascx. Below is the markup for FirstControl.ascx:


<%@ Control Language="C#" AutoEventWireup="true" CodeFile="FirstControl.ascx.cs" Inherits="FirstControl" %>
<<%@ Reference Control="~/WebUserControl.ascx" %>
<hr />
<h3>First Control</h3>
<asp:CheckBox ID="chkMaster" runat="server" />&nbsp;&nbsp;<asp:Button ID="btnFirstSubmit" Text="First Submit" OnClick="btnFirstSubmit_Click" runat="server" />
<hr />

And here’s the code behind for FirstControl.ascx:


protected void btnFirstSubmit_Click(object sender, EventArgs e)
 {
 if (chkMaster.Checked)
 {
 // show the other control
 WebUserControl wuc = (WebUserControl)LoadControl(typeof(ASP.gis), null);
 PlaceHolder holder = (PlaceHolder)FindControlRecursive(Page, "ControlHolder");
 holder.Controls.Add(wuc);
 }
 }

When the submit button on the FirstControl.ascx (provided the checkbox is checked), the user control will dynamically load the WebUserControl.ascx which contains a textbox, a submit button and a literal to print out the name in th e textbox. The WebUserControl is loaded properly but when its submit button is clicked, it will disappear on postback.

Solution: The reason for this is that the parent page (Slave.aspx) does not know of its existence. Therefore we need to make the page aware of it. When you load a dynamic control, you need to keep track of it, whether through ViewState or Hidden Form Field. I’ve used a hidden form field in this instance and here’s the code in the FirstControl.ascx file:


protected void btnFirstSubmit_Click(object sender, EventArgs e)
 {
 if (chkMaster.Checked)
 {
 // show the other control
 WebUserControl wuc = (WebUserControl)LoadControl("~/WebUserControl.ascx");
 wuc.ID = "wuc";
 PlaceHolder holder = (PlaceHolder)FindControlRecursive(Page, "ControlHolder");
 holder.Controls.Add(wuc);

 HiddenField hf = (HiddenField)FindControlRecursive(Page, "hf");
 hf.Value = "1";
 }
 }

Important thing to note here is that we need to make sure that we assign a unique ID to the dynamic control. And here’s the code behind for Slave.aspx:


protected void Page_Load(object sender, EventArgs e)
 {
 if (hf.Value == "1")
 {
 WebUserControl wuc = (WebUserControl)LoadControl("~/WebUserControl.ascx");
 wuc.ID = "wuc";
 ControlHolder.Controls.Add(wuc);
 }
 }

So to prevent the dynamic control from disappearing, you need to keep track of whether you’ve added it or not and load it if you have.

Loading a dynamic user control without specifying the path

If we want to load our control when some action is performed and not have it sit there and go through the asp.net life cycle for no reason, then we need to add a reference to the user control in the parent page. Now LoadControl is the method we’re after and it has 2 overloads. The first one requires a path to the user control and that works flawlessly. The second one takes a strong type and a parameterised object.

Casting the control to the right type

If you have properties on the control, you will need to cast it to the right type. Otherwise your properties won’t be available to you. The following code does not give me the intellisense for the public properties on WebUserControl because it’s been casted as a generic UserControl.

UserControl myUserControl = (UserControl)LoadControl(“~/WebUserControl.ascx”);

To access these public properties, you will need the following code:

WebUserControl myUserControl = (WebUserControl)LoadControl(“~/WebUserControl.ascx”);

Remember that you need to reference the WebUserControl in the parent page, otherwise you’ll get a compile time error:

<%@ Reference Control=”~/WebUserControl.ascx” %>

Dynamically loading the control by type

If you want to do the following, you will not see your control loaded:

WebUserControl myUserControl = (WebUserControl)LoadControl(typeof(WebUserControl), null);

This is because when you use the path to the user control, asp.net will fire off all the events that the control has missed until it catches with the current event. So if you’re adding a user control in the button click event, the init and load event have already passed, so the newly added control need to catch with the events until it is in sync. The workaround is to strongly type the user control and you do this by adding the ClassName attribute to the control’s markup as follows:


<%@ Control Language="C#" AutoEventWireup="true" ClassName="gis" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
<hr />
<h3>Web User Control</h3>
<asp:Literal ID="litSomething" runat="server" /><br />
<asp:Literal ID="litText" runat="server" /><br />
<asp:TextBox ID="txtName" runat="server" />
<asp:Button ID="btnSubmit" Text="Submit from user control" runat="server" OnClick="btnSubmit_Click" />
<hr />

Notice the ClassName=”gis” in the code above. Now you would assume that you can do something like this:

WebUserControl myUserControl = (WebUserControl)LoadControl(typeof(gis), null);

But that won’t work because the ClassName “gis” cannot be found as it resides in the ASP namespace. Here’s how to do it properly:

WebUserControl myUserControl = (WebUserControl)LoadControl(typeof(ASP.gis), null);

You will get “System.MissingMethodException: Constructor on type ‘ASP.gis’ not found.” if you try to pass in parameters though:

WebUserControl wuc = (WebUserControl)LoadControl(typeof(ASP.gis), new object[] { “hey you” });

For some reason asp.net is unable to get the overloaded constructor for the user control even though it’s private. From what I’ve read, only the parameterless constructor is called.

Where to add dynamic controls? Page_Init, Page_Load?

You can add them whenever you want but if you don’t add it in Page_Init, the control will not be able to participate in ViewState as the loading of view state comes before page load.

Events available to User Control

You can use Init, Load and PreRender.

Buying expired domain names and making money from them

Going into the expired domain names business can be very rewarding if you know what you’re doing. Most people purchase expired domains as a quick way to make money from them while a few just want to get hold of a particular domain. Here we’ll be talking about how to get the most of expired domains.

How long after a domain expires do you have to wait until you can purchase it?

There are hundreds and hundreds of domains which get expired everyday because they are not renewed by their owners. However I’ll be concentrating my efforts on the .uk domains here. After a domain expires, there’s a 30 day grace period where the owner can still renew the domain. If the domain is not renewed, it goes into a 60 day suspension period where the name servers do not resolve. After that, there’s an additional 2-9 days before the domain becomes available again. So basically, you’re looking at 92-99 days before you can grab an expired .uk domain name.

Why would you choose an expired domain name over another?

There are two essential things to take into consideration when buying a domain that has expired. First is the Google PageRank (PR) and second is the traffic that it receives. There are ways for you to get a glimpse of the traffic for a particular domain like hitwise.co.uk but unless you keep all of the website’s content, the traffic will soon vanish. The problem with reconstructing the same content is that you will end up infringing intellectual property rights. That being said, traffic can also come in terms of referrals from other websites. For example, if there’s a link to that expired domain on a popular website, then you can get a lot of traffic from that.

Most people find it easier to work with PageRank though. The higher the PR of the expired domain, the better it will be for you because we will be able to sell links on that domain at a much higher price and that’s what a lot of link sellers do, ie, grab expired domains, and sell links on them. Link buyers will look at the PR and think there’re getting a really good deal when it’s not really.

If you can see the PR of the expired domain just before it expired, you can make your own decision on whether to get it or not. However PR is just a reflection of the quantity and quality of backlinks. So if the important backlinks are removed, the PR of the website will decrease as well. The best way to know if an expired domain is really worth buying is going to Yahoo Site Explorer and looking at the backlinks. Go to the webpages where the link is placed and check the corresponding PR of the webpage, if it has a high PR, then it’s good. Also check how far down the bottom the backlink is placed. The higher up the webpage, the better the backlink and the fewer the number of outgoing links, the greater link juice you will get.

Backlinks from .ac.uk or .org.uk or gov.uk websites are likely to have a higher PR than others. However sometimes sites with other extensions have high PR as well and that’s why you will need to check them all to make sure you’re not missing out. Somestimes you’ll get a decent backlink from bbc.co.uk and other newspaper as well.

How to maintain the PR of an expired domain?

Once you’ve got a expired domain with a decent number of backlinks, you can pretty much guess what PR it will get during the next PageRank update. This will depend on the quantity and quality of the backlinks. However there are some steps that you will need to take to ensure that the PR is not reset for that domain. Some people just buy the expired domain and throw in content which is completely different to what was on that domain before and then wonder why the PR has been reset to zero and become N/A (not applicable). If you want to preserve the PR, you will need to have a similar theme to what was there before. Go to archive.org and look at the website when it was live. Make sure you write content similar to what was there before and try to keep the title tag of the homepage as closely as it was before. It is important that you do not just copy the same exact text from archive.org as this would be infringing copyrights. And do not attempt to ressurect the website by reconstructing the website from archive.org’s copy.

How to get revenue from your expired domain?

You can get a decent income from buying an expired domain by selling blogroll (sitewide links), blog posts with links to sponsor sites or placing banners on it. You can also put relavant ads by using Adsense, in-text advertising like Kontera/Infolinks or Adsense for Domain. You will find a lot of interest on forums.digitalpoint.com Link Sales section and most people will prefer to pay through Paypal.

Expired domains and SEO

Many seo professionals will say that it is useless to buy expired domains but that’s not entirely true. For a Search Engine Optimisation (SEO) point of view, the domain will lose its authority once it is dropped. That is why it is better to transfer ownership before a domain get dropped if you still want it to rank for its search terms afterwards. In the case of expired domains, what I’ve seen is that you will still get traffic from referring sites where your backlinks are placed and some organic search as well if you keep the same theme. You will need to check the raw log file access and see which deep pages are being requested from referring sites and try to ressurect these ones to preserve the pagerank and possibly get organic search traffic from it as well.

It is more difficult to make an expired domain rank for its search terms as it was before but you could try link building for the site and keeping the same content. And if you just want to make quick cash from it, then all you need is a high PR and some naive link buyers who do not take the time to research the domain onto which they’re buying links to see if it has been dropped before.

Application pool recycling – The not so obvious reason

If your application pool is recycling for no reason, it could be a problem for your visitors because the loading time of your webpages will be increased. Nobody likes slow websites and this can discourage people from coming to your site and this is why you need to fix the problem as soon as possible.

On one of my sites hosted on a Windows 2008 R2 server, I’ve got a dedicated app pool for a website. However I’ve noticed that the application was recycling quite often and this impacted the load time of the website. When any page from the website is loaded for the first time, the web app does a number of things including caching of certain data and loading some necessary classes for it to function properly. This needs to be done only once and any further HTTP requests should be fast from then onwards.

Drilling down into the problem, I found that the application pool has a default timeout setting of 20 mins. This means that if no requests are made within 20 mins, the app pool will be shut down. This is only good if you have a lot of app pools running and running low on memory. However for a low traffic site where you don’t necessarily have visitors within every 20 min interval, your app pool will recycle and the next visitor that you get will see the page load really slowly because startup methods are being called by your web app. To prevent this from happening, you need to set the Idle Time-out (minutes) property in the app pool to zero (0).

You should also set the Regular Time Interval (minutes) to 0 to avoid your application from recycling at specific period of times. It’s also a good idea to enable Event logging for when your application pool is being recycled so that you can easily know if there’s any problem with your website.