Monday, 13 April 2015

Runtime error set custom mode off in asp.net website

Hi Readers,



Today i have come up with a post which is a solution to the Runtime error occuring on the live
server in Asp.net website.

A website runs perfect in your visual studio development server but throws error in liver server.

when a asp.net website is uploaded or moved to a live server in a hosting provider web space, often this runtime error comes into play.

Runtime error: A error which occurs when the aspx page is parsed to display the contents.

A runtime error comes with a message to set custom error mode off.

A custom error is the error displayed as set by the server, by making it to set off you can get the exact error as you get while you test your website in visual studio development server. This error may occur due to following reasons.

1) incompatible .net version
2) incompatible sql version
3) error in masterpage call
4) error in page redirects.
5) error in queries.
6) error in web-config file

so here is the solution, in most of the sites you will find only a compact solution limited to just first two or 6th. Here i am sharing my personal experience about troubleshooting it.


First step: Set custom error mode to off


here is the syntax and is case sensitive so just copy paste it in web-config file.


<system.web> <customErrors mode="Off"/> </system.web>


Second step:

                         If your site is using an extension domain like www.examples.com/mywebsite then on the top of page in the call for master page add the folder name in which your master                  page is kept.
 for example if i have a website in www.examples.com and i have uploaded a folder called mywebsite in which my masterpage resides. 
then the master page call syntax will be ~/mywebsite/masterpage.master


<%@ Page Title="" Language="C#" MasterPageFile="~/mywebsite/master.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

  


Third step: 

                      if any page is kept in subfolder then use the similar method to call the page at redirects like the master page call.


    Response.Redirects("~/subfolder/pagename");

   

 Fourth step:

                      In live server if your website is in a subfolder or in many live server the subfolder calls results in runtime error so never use the class file in appcode folder to write your connection class.
I know its wrong and not efficient coding but its a only way out, don't use the class file write connection calls and connection string at every place where you wrote the query. 
Put the connection calls in local scope.

Use the connection string provided by the live server without making any changes to it.

if you have used drop-downlist calls in queries then u also need to change the connection string in webconfig file.


Fifth step:

   check the .net framework version of your hosting provider. if it uses different version just        make the target framework change to that version and it will work.
 I know there are website which tells that incompatible framework can't work and sites need to be redesigned but try my tricks and see for yourself.


Sixth step:

 Sql server version unsupported , then dont use FTP to transfer database, just click on the             database in your live server and create a database with the same name as your local database, and create the same tables and fill the data manually.


Seventh step: 

 Run your website by typing the url and clicking on go, and see its working or not, if not               you will get a error which will indicate the proper place where you have got it.Just try to troubleshoot it you will be able to do it, if you have developed the local website.


If you have any queries, your comments are invited, 

No comments:

Post a Comment

About the author

Scholar Ratan pal singh is a Google scholar, a man with innovative ideas and a nothing is impossible attitude, is a tech-lover.
He works as a independent researcher and freelance website and software developer.
Member of IEEE comsoc society, Green technology society and has published research paper and codes in many international journals and opensource.

"Failure is the pillar of success and Honesty with oneself is the only true way of achieving self-confidence."

Translate

Pageviews