How to check if Global.asax file is called

It is difficult for me to execute the On_Error event in the Global.asax file. When the application receives an error, it should go to the Global.asax file, register the error in the database and redirect to the user error page. The above code works fine in my local, but as soon as I deploy it on a DEV machine, Global.asax is not executed.

It always redirects to the custome error page specified in web.config

<customErrors mode="On" defaultRedirect="/Error_Redirect.asp">
        <error statusCode="404" redirect="/404.asp"/>
    </customErrors>

The structure of the project in IIS is similar to Test1 \ Test 2. The error handling code that I am trying to use is in Test 2 and its virtual dictator in IIS. If I have an error in the web.config file, for example, "The section has already been mentioned", then the error gets into the Global.asax file. If there are any runtime errors, as shown below, it does not fit the Global.asax file.

Int32 i, j, k;
i = 10;

j = 0;

k = i / j;

Response.Write(k);

. I'm even tired setting Off / RemoteOnly. Any suggestions?

Thank,

+5
source share
3 answers

You should try to remove the precompiledapp.config file from root. (at least temporarily rename it)

+2
source

. URL, . - URL-, , .

ctrl shift , .

, asax , - global.asax.

HttpContext.Current.Response.Write("TEST");
HttpContext.Current.Response.End();
+1

, ASP.NET? "Test1/Test2" , , - URL-, , "Test1/Test2" , "Test2"?

I recently worked on POC in ASP.NET and mistakenly transferred Global.asax to a subfolder, not to the root application. I was expecting some code in the application launch event to be triggered, which never worked. After you return to the root application, it starts working as expected.

So, when you call through "Test2", your Global.asax exception handler fires, when you call through "Test1 / Test2", then your Global.asax does not work.

0
source

All Articles