.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Need help with a custom error page that shows the error message details

Posted By:      Posted Date: October 16, 2010    Points: 0   Category :ASP.Net

I know how to alter the web config to redirect to an errors page but what I need to do is have the actual offending error message print to that page. This is a special request for testing reasons, I realize the whole point of a custom error page is to provide a user friendly message when an error occurs but for testing we want to show the user the message so they can copy and paste it into a ticketing system we are using for beta testing feedback.

Should I use the global.asax instead? I am pretty new to vb.net and am not sure how to get the actual error message to display on my custom error page. Any guidance would be greatly appreciated.


View Complete Post

More Related Resource Links

Pass exception details to custom error page.

Hi All, I created a custom error page and update using webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Error, CustomErrorPage). Its working fine and my custom error page is show if error is occurred. OR We redirect using SPUtility.RedirectToErrorPage("my message"); But I am not able to find my exception details at my custom error page. Is there any way to pass the exception details and other custom information to custom error page?  

Null reference message Custom Error page

how come a Null session value that is called, doesn't get directed to the Custom Error Page?

Very Basic Question - Error message running first page


Hi Everyone,

I am running Windows 7 and I have gone into Control Panel and activated all of the IIS Functions.

The web application I am running was downloaded from the net (and has worked on other machines previously).  Once I downloaded it, I moved it into C:/inetpub/wwwroot/code/main.asp

I am a bit of a novice at this!  But I am hoping someone can point me in the right direction!


I get the following error when I try and run the web application through IE:

"An error occurred on the server when processing the URL. Please contact the system administrator. If you are the system administrator please click here to find out more about this error."

(When i click the "click here" button it just goes to the IIS site).


Appreciate any help I can get!




Custom error page

Hi all,I'm having VS 2008 professional. I want to generate a custom error page in my website. I added simple .htm file and wrote in it whatever i wanted it to display. Then I went to ASP.net configuration > Application > Define default error page and then selected my .htm file & saved it. After that if i tried to view my website in browser, it is not showing me the error page which i created instead it is showing the server error page which VS generally shows if there is some error in the code. Plz help to sort outSmitha

"403 forbidden" Error in my Custom login page

Hi All,   I Created a custom login page using Sharepoint Application page which is cofigured with FBA using this article http://blogs.msdn.com/b/kaevans/archive/2010/07/09/creating-a-custom-login-page-for-sharepoint-2010.aspx. But I keep getting the "403 forbidden" error. Can anyone suggest me a solution. Thank you.

Displaying custom error page


For certain parts of the site the allow inserting and updating of data we have some try / catch logic in place..

Now we would like to display a custom error page explaining what didnt happen. Instead of just a generic message that says error occurred.

Here is 1 error that is generated due to Primary Key constraints, we woudl like to redirect them to our error.aspx page which is already setup and configured in the web.config but within that page display a more user friendly detail message of why they got the error. In the example below, we may want to say, "There was an error with the "Access Insert" please make sure that the values you entered on the previous page are unique" thats just an example, but gives an idea of what we are trying to do.



Server Error in '/' Application.

Access Point Insert Error:Violation of PRIMARY KEY constraint 'PK_AccessInfo'. Cannot insert duplicate key in object 'dbo.AccessInfo'.
The statement has been terminated. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Exce

The page cannot be displayed error when creating new item in custom list


Hi i am workign with a cutom list and every time i try to add a new item and hit ok i get the error shown below. Sometimes it happens and other times it doesnt and it only happens with a select few. One way of getting around this error is to not edit it on the page on which it is on but to go to view all content then to the custom list.

I have tried observing whether there was an issue with the pages being checked in and checked out but all pages were checked in and published. I tried deleting and recreating the custom list and no luck. Your feedback would be much appreciated! Thanks in advanced

btw i am a user with full control and our site is being hosted.

The page cannot be displayed


creating custom error page


Hi ..

I have two errors in my application i want to display a custom  defferent error page for each error...

Here is my code

protected void Button1_Click(object sender, EventArgs e)
            int a = 10;
            int b = 0;
            int c = a / b;
      // FIRST ERROR

    protected void Button2_Click(object sender, EventArgs e)

            string str = "hjdfgjh";
            int vv = Convert.ToInt32(str);
        //SECOND ERROR

i have configured web.config like b

Access Denied Error Message from Custom Webpart



I am new to MOSS so can anyone please help me to solve this problem.


I've a list in MOSS-2007, and a group of people with Read Only Rights so they cannot change any list item. But I want to give them access to edit one column (i-e Comments) in that list.

So I created a custom web part page and put a comments text box in it. At DispForm.aspx page of list there is a link which redirects to Custom page for adding comments and I am passing Item ID in query string.

But the problem is that when anyone adds the comment on custom page an ACCESS DENIED message appears. I've even set "web.AllowUnsafeUpdates = true" but didn't work


                SPWeb web = SPContext.Current.Web;
                SPList lstTIX = web.Lists["ListName"];


Response.Redirect cannot be called in a page callback error message.


Hi.  I'm using the Dundas Chart Controls in VS 2005.  These controls are built utilizing AJAX.  I have a basic page with a dundas chart control containing a funnel chart.  The funnel contains Quotes, Sales Orders and Invoices.  When the user clicks on the control, I want to determine whether they clicked on Quotes, Sales Orders or Invoices and transfer to the appropriate Details Page.  I've got the code working to determine which transaction type they clicked on; but, I get the "Response.Redirect cannot be called in a page callback." error when the page tries to redirect.  Note: I get a similar issue if I try server.transfer.


 Here's my code:

Dim hitTestResult As Dundas.Charting.WebControl.HitTestResult = Chart1.HitTest(e.X, e.Y)

            If Not (hitTestResult Is Nothing) Then

                Dim clicked As Dundas.Charting.WebControl.DataPoint = hitTestResult.Series.Points(hitTestResult.PointIndex)

                Select Case hitTestResult.PointIndex
                    Case 0


I can not create Article page in publishing site with a error message related to Microsoft SharePoin


I installed MOSS 2010 successfully with all requirements and options. After that It created a Publishing site. But, when I create an article page for news, the error page show that:


File Not found Trouble Shoot issues with Microsoft SharePoint Foundation (*).

Correlation ID: 5cce256-b30b-477d-9820-c46238f224a

Date and Time: ...


*:it's a link to open an error windows like this Besides, if i create a site with other templates (not Publishing template), I can not also start Publishing feature

"403 forbidden" Error in my Custom login page, cant find problem

I Created a custom login page using Sharepoint Application page which is cofigured with FBA.  but every time redirect to http://testsp.max-perf.com/_layouts/DataQ.Extranet/test.aspx?ReturnUrl=%2f_layouts%2fAuthenticate.aspx%3fSource%3d%252F&Source=%2F .  I have  Win2008 (not r2) and sp2010. Thank you.

Web form shows error message even when there is no errors!


Hi there,

I'm new to c# and I seem to be having a problem with an error message. If my textbox is left empty my code will throw a format exception and display the message in a label. If I then add a number to the textbox it runs correctly but the error message remains.

Any idea what am I doing wrong?


protected void btnTemp_Click(object sender, EventArgs e)
            float temperature;

                temperature = float.Parse(txtTemp.Text); 

                if (temperature < 15)
                    lblHotCold.Text = "COLD!";
                    lblHotCold.BackColor = Color.Blue;
                else if (temperature > 15 || temperature == 15)
                    lblHotCold.Text = "HOT!";
                    lblHotCold.BackColor = Color.Red;
            catch (FormatException)
                lblErrorMsg.Text = "Textbox can't be left empty";

Cheers Smile

Custom Error Page question


I create my own customize error page. The code fragement for catch the eroor as following:

HttpCompileException _ccExp = null;
string _expType = "RunTime Error...";
Exception _lastError = Server.GetLastError();

// Get the Stack Frame
if (_lastError is HttpUnhandledException && _lastError.InnerException != null) _lastError = _lastError.InnerException;
//StackTrace stack = new StackTrace(_lastError.GetBaseException(), true);
StackTrace stack = new StackTrace(_lastError, true);
for (int i = 0; i < stack.FrameCount; i++)
	if (!String.IsNullOrEmpty(stack.GetFrame(i).GetFileName())) {
		_frame = stack.GetFrame(i);
if (_frame == null) _frame = stack.GetFrame(0);

// Get file name
string _fileName = _frame.GetFileName();

I try get the .aspx file in the last line, "string _fileName = _frame.GetFileName();".
Why I got a url-formed file name such as "http://server/Work/SomeOne.aspx", sometimes,
and other time, I got a physical path such as "D:\websites\MySite\wwwroot\Work\SomeOne.aspx" ?


Page IS Valid Validation Error and Message Box Pops up twice which is annoying???




i have a create User Wizard with a Custom Template so I can grab more information from the user who is

registering on my page.  When they click the submit button a window modal popup extender pops up using Javascript code to

show them the Form is being processed.


createUserWizard Submit Button

  <asp:Button ID="StepNextButton" runat="server"  CommandName="MoveNext"  OnClientClick="ShowMP();" align="middle" CausesValidation="False"
                                            Text="Submit my Profile"  />


Javascript code<

404 Page Not Found Error When Trying to Create a Site From a Custom Site Template


I just moved a site collection from a one server to another, and now I can't make copies of my sites using custom site templates.

The details of my site structure are in the next paragraph, in case they are relevant.
On the original server, I created custom templates for my sites, and checked the Include Content checkbox
when creating the templates. Everything works perfectly on that server. When I moved the whole site collection to another
server using stsadm backup/restore everything was there, including my customized web parts. But now I can't create new sites
from templates - and I'm I'm not trying to use templates created on the original server. I'm creating new templates on the new
server. It successfully creates the templates, but when I try to create a new site from one of those templates, I get a
"HTTP 404 Page Not Found" page. It succeeds in creating the new site, and the new site shows up in my navigation bar,
but when I click on the new site, I get a "404 Page Not Found" page.

On the original server, I created one top level site for my whole department. Under that, I have one subsite for each of our
external clients. Under each of those, I have one subsite for each project for that client. I used a Team site as my starting
point at each of the 3 leve

Showing Custom Error Page using asp.net mvc


Hello Friends,

I am showing Custom Error in my page.. if somehting happend wrong. but if the same error occured in my subview master page I am not able to show the Custom error page on Entire page its showing me that Error page under subview master page. Please I am attching the Screen shot.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend