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

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

Custom Error Page question

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

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" ?


View Complete Post

More Related Resource Links

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!




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?  

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

Null reference message Custom Error page

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

"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

"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.

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


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.


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.

Update Error in Custom Page



I'm trying to update a record in gridview layout in Student Guardian table.  I'm running into the error below:  "Failed to set one or more properties on type StudentGuardian. Operation is not valid due to current state of the object."


[LinqDataSourceValidationException: Failed to set one or more properties on type GRIPS.StudentGuardian.  Operation is not valid due to the current state of the object.]


access denied error in custom login page using custom membership provider/ roleprovider in the FBA u



I have deployed my custommebrship assembly and role provider assembly in the sts web config , central admin web config  and current web appln web config 's. i have created a  dll which has  login control and in the sign_authenticate event i am creating the securitytoken.

when i establish a session using the security token created using the iissettings object, and  while tryibng to redirect to the   home page of the/landing page of the web appln am Getting access denied error. 

signInControl_Authenticate(object sender, AuthenticateEventArgs e)




e.Authenticated = true; //till this line  it worked success.

 base.RedirectToSuccessUrl(); //here it throws  :" Eror: access  denied "     current ly signed in user : myname sign is as   diuff. user


anybody knows how to overcome this , means authentication is  success, but authoriation didnt work.

 how can i get asuccessfull login to theweb appln/ siteccollection? in my role provder class i  have created my own roles

for user name: myname

role name:  Administrators, Contributor.

any help is appreciated





Getting an error while attaching the master page to custom .aspx


Hi ,

I am getting the following error while I am trying to attach the master page to the custom form

The virtual path '/_catalogs/masterpage/default.master' maps to another application, which is not allowed.

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.ArgumentException: The virtual path '/_catalogs/masterpage/default.master' maps to another application, which is not allowed.

Actually I am developing the association form in the custom work flow , I am calling the master on the On PreINt event of the page



SSRS -Web.config - Custom error page


There is a requirement to show error page whenever there was an error either while selecting filters or report processing, user would be accessing the reports directly from reportmanager url.


As we know, SSRS is also a asp.net web site with web.config file and customError tag is used to redirect user to a custom error on any error. Following is snippet of code taken out from web.config of asp.net project.


web.config of asp.net project.

      <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

            <error statusCode="403" redirect="NoAccess.htm" />

Handling 404 page not found with Error page



      How do i handle 404 page not found?

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