Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide source error (lines of code) when throwing exception

Tags:

c#

asp.net

How can I hide line of source throwing an exception in yellow screen of death? For example, consider following screen of potential dangerous request:

enter image description here

In above example, source lines are not displayed. Whereas, if it is any custom written code throwing an exception, lines of error are always displayed as following:

enter image description here

How can I hide lines of code (similar to first image) when throwing an error?

like image 225
helloworld Avatar asked Dec 28 '22 03:12

helloworld


1 Answers

Set the mode attribute of the customErrors section to RemoteOnly in your "web.config" file:

<?xml version="1.0" encoding="utf-8"?>

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" />
    </system.web>
</configuration>

This enables you to see detailed errors when you are browsing the website locally on your server but does not expose detailed errors for remote visitors.

Alternatively, set it to On instead of RemoteOnly to completely hide detailed errors, no matter whether you are browsing remotely or locally.

like image 159
Uwe Keim Avatar answered Jan 19 '23 08:01

Uwe Keim