While hosting change seems like just copying file from one ftp location to another ftp location. It some time create a real headache, once after moving you file you find out that the new hosting is performing 100 times slower than your previous hosting.I tried the same an dig in the same problem.
First you need to setup you website in such a way that it will notify on about the errors received.
Simply add a new function(Application_Error) inside GLOBAL.ASAX or simply paste the code in braces if it is already present.
public void Application_Error(object sender, EventArgs e)
{
string ErrorMessage = "The error description is as follows : <br/>Source:<br/>" + Server.GetLastError().Source.ToString() + Environment.NewLine +
"<br/>Message:<br/>" + Server.GetLastError().Message.ToString() + Environment.NewLine +
"<br/>Stack Trace:<br/>" + Server.GetLastError().StackTrace.ToString() + Environment.NewLine +
"<br/>Data:<br/>" + Server.GetLastError().Data.ToString() + Environment.NewLine;
ErrorMessage += GetUserData();
SendMail("toWhomItMayConcern@erroneous.com", " toWhomItMayConcern@erroneous.com ", "Error in site", ErrorMessage);
}
string GetUserData()
{
System.Web.HttpBrowserCapabilities browser=HttpContext.Current.Request.Browser;
string s = "Browser Capabilities<br/>"
+ "IP Address = " + HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString() + "<br/>"
+ "Type = " + browser.Type + "<br/>"
+ "Name = " + browser.Browser + "<br/>"
+ "Version = " + browser.Version + "<br/>"
+ "Major Version = " + browser.MajorVersion + "<br/>"
+ "Minor Version = " + browser.MinorVersion + "<br/>"
+ "Platform = " + browser.Platform + "<br/>"
+ "Is Beta = " + browser.Beta + "<br/>"
+ "Is Crawler = " + browser.Crawler + "<br/>"
+ "Is AOL = " + browser.AOL + "<br/>"
+ "Is Win16 = " + browser.Win16 + "<br/>"
+ "Is Win32 = " + browser.Win32 + "<br/>"
+ "Supports Frames = " + browser.Frames + "<br/>"
+ "Supports Tables = " + browser.Tables + "<br/>"
+ "Supports Cookies = " + browser.Cookies + "<br/>"
+ "Supports VBScript = " + browser.VBScript + "<br/>"
+ "Supports JavaScript = " + browser.JavaScript + "<br/>"
+ "Supports Java Applets = " + browser.JavaApplets + "<br/>"
+ "Supports BackgroundSounds = " + browser.BackgroundSounds + "<br/>"
+ "Supports ActiveX Controls = " + browser.ActiveXControls + "<br/>"
+ "Browser = " + browser.Browser + "<br/>"
+ "CDF = " + browser.CDF + "<br/>"
+ "CLR Version = " + browser.ClrVersion + "<br/>"
+ "ECMA Script version = " + browser.EcmaScriptVersion + "<br/>"
+ "MSDOM version = " + browser.MSDomVersion + "<br/>"
+ "Supports tables = " + browser.Tables + "<br/>"
+ "W3C DOM version = " + browser.W3CDomVersion + "<br/>";
return s;
}
public void SendMail(string sTo, string sFrom, string sSubject, string sBody)
{
MailMessage msgMail = new MailMessage();
msgMail.To = sTo;
msgMail.From = sFrom;
msgMail.Subject = sSubject;
msgMail.BodyFormat = MailFormat.Html;
msgMail.Body = sBody;
try
{
SmtpMail.SmtpServer = System.Configuration.ConfigurationManager.AppSettings["SMTPAddress"].ToString();
SmtpMail.Send(msgMail);
}
catch (Exception ex)
{
System.Web.HttpContext.Current.Response.Write(ex.Message + "<br>");
}
}
This will help you identify the exact problem and send you an enormous amount of data to help you keep track of error.
Now checkout what type of errors you are receiving.
1. Exception of type 'System.Web.HttpUnhandledException' was thrown.
There errors are the most frequent which I received, it occurs due to the following reason
· EnableViewStateMac not set to “false” in web config so I made is so
<pages viewStateEncryptionMode="Never" validateRequest="false" enableEventValidation="false" enableViewState="true" enableViewStateMac="false">
2. You are receiving other sort of error somewhat related to Viewstate validation, this might be due the fact web hosting company have been using more than one server to load balance you site and other sites on server.
a. <machineKey validationKey="AE65E95A0B55E96C4688AECFB17381EDAA3BC125DE3869643D430CE27E53D236878806245332E033D8F85A68E0C68CF5309D106F20B5C297979F7620C8358F6A" decryptionKey="8C8ED732A8D973B303E152BBD5F5421DD2E4D3C6396B595A" validation="SHA1" />
3. Also you need to show custom error pages which can be done using
a. <customErrors defaultRedirect="~/GeneralError.aspx" mode="On" />
4. Some time you also need to get Inner Exception Message as well to monitor. For example you are receiving an unhandled exception but once you dig in using Inner Exception Message you might find anything useful
5. Some time you receive different pages link which are stale and not present on you site. This can be due to the following facts
a. You previous page, which now are stale, might be reference or published inside any forum.
b. Sometime Search Engine bots also keep searching you site based on their list and through this sort of exception
1. You can use a ROBOTS.txt file to suggest bot engine to bypass some pages.
There do exist other experiences as well while shifting the hosting of a site. I have tried to scratch my mind and find these stuff. If any found later I will update this posts.
Thanks for reading.
No comments:
Post a Comment