Click here to Skip to main content
16,019,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,

Question : when i run the application from IP
application_error is not fire?
but when i debug from VS2012 is fire.

global file code
-----
C#
void Application_Error(object sender, EventArgs e)
    {
        // Code that runs when an unhandled error occurs
        try
        {
            Exception exc = Server.GetLastError().GetBaseException();
            if (exc.GetType() == typeof(HttpException))
            {
                // The Complete Error Handling Example generates
                // some errors using URLs with "NoCatch" in them;
                // ignore these here to simulate what would happen
                // if a global.asax handler were not implemented.
                if (exc.Message.Contains("NoCatch") || exc.Message.Contains("maxUrlLength"))
                    return;

                //Redirect HTTP errors to HttpError page
                //Server.Transfer("HttpErrorPage.aspx");
            }
            //ExceptionUtility.LogException(exc, "");
            SendExcepToDB(exc);
            Server.ClearError();
        }
        catch( Exception ecv)
        {
            throw ecv;
        }
    }
------------------
and in web config below

------------
XML
<configuration>
  <connectionstrings>
  
  <system.web>
    <compilation debug="true" targetframework="4.5">
    <customerrors mode="On">     
    
  
 
    <system.webserver>
      <httperrors existingresponse="PassThrough">
        <defaultdocument>
            <files>
                <clear>
                <add value="Default.aspx">
                <add value="Default.htm">
                <add value="Default.asp">
                <add value="index.htm">
                <add value="index.html">
                <add value="iisstart.htm">
--------------
Can any one suggest me the solution?

What I have tried:

i want to find the solution of given problem above.........:)
Posted
Updated 30-Nov-16 18:14pm
v2
Comments
Kornfeld Eliyahu Peter 30-Nov-16 9:42am    
How did you published your site? Have you checked that all parts are in place? Maybe you have a different web.config for run-time (VS creates two!)?
BIKASH KARMAKAR 30-Nov-16 23:55pm    
No site is not Published, its run with code in IIS. and Debug is True.
yes all the parts are in correct place.
No web config is same,no any changes in that as i posted above
BIKASH KARMAKAR 1-Dec-16 0:20am    
Thank you for suggestion.

Let me try first.. if any thing i let you know

1 solution

First read the explanations at MSDN[^]...
Now the part not in there... When mode is ON the default error handler not called on unexpected errors - but redirected immediately to the custom error page - except you are on localhost (and in debug mode)...
The moment you are browsing with the IP it considered not local and you get no hit for the error handler, while from VS you are going to localhost...

A good reading: Complete Example for Error Handlers[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900