Try our conversational search powered by Generative AI!

Enabling friendly messages on localhost

EVT
EVT
Vote:
 

(Yes, it is embarrassing but it is as it is : D )

We do not seem to know / remember how to enable friendly error messages on a localhost (or how they are configured overall).

 Friendly error message:

On localhost we get the full stack message.

I have googled the issue and tried to change the web.config accoring to this link but then it expects me to provide the actual file that should be displayed instead of the error message.

Also in integration web.config where we get friendly messages this setting does not exist.

So where is it configured then? Where and how is it enabled and how is it determined which file(s) to show instead of the full error message?

#299513
Edited, Apr 04, 2023 13:56
Vote:
 

Have a look at the globalErrorHandling property in your applicationSettings

Set whether to use EPiServer CMS error handling with the following possible values: On, Off or RemoteOnly.
  • On. EPiServer CMS hides the original error and a generic error message is displayed instead.
  • Off. Errors are not handled by EPiServer CMS. Errors will be handled by ASP.NET as defined in the customErrors element.
  • RemoteOnly. Error handling is On for all visitors except for those accessing the site from the web server itself.

This can also be controlled via the Admin interface 

If this is set to Error handling off it will use what you have set in the web.config i.e we have 

    <httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404" />
      <error statusCode="404" path="/NotFound" responseMode="ExecuteURL" />
      <remove statusCode="500" subStatusCode="-1" />
      <error statusCode="500" path="/500.aspx" responseMode="ExecuteURL" />
    </httpErrors>
#299522
Edited, Apr 04, 2023 15:13
EVT
Vote:
 

I have changed this setting to OFF in the environment where we have friendly error messages but nothing has changed, I am still getting the nice view. 

At the same time I have only this on locahost 

And I do not know where to copy the settings from other environments, i.e., those where friendly messages are enabled, from. These settings do not exist in these files

#299568
Apr 05, 2023 6:26
Vote:
 

Try

<httpErrors errorMode="DetailedLocalOnly" existingResponse="Auto" />
... or
<httpErrors errorMode="Detailed" existingResponse="Auto" />

Also

<system.web>
    <customErrors mode="Off" />
</system.web>
#299570
Apr 05, 2023 7:23
EVT
Vote:
 

@Eric, tried your suggestion, no change, still getting Stack Trace. 

Changing the setting in Admin to 

returns this

instead of 

and yet still it is not this, which is what I am looking for...

#299911
Apr 11, 2023 11:11
Vote:
 

Sorry, I missunderstood your post 😣

Here's what we do to hide error messages in dev

<system.webServer>
  <httpErrors errorMode="Custom" existingResponse="Auto">
    <remove statusCode="400" subStatusCode="-1"/>
    <remove statusCode="401" subStatusCode="-1"/>
    <remove statusCode="403" subStatusCode="-1"/>
    <remove statusCode="404" subStatusCode="-1"/>
    <remove statusCode="410" subStatusCode="-1"/>
    <remove statusCode="500" subStatusCode="-1"/>
    <error path="/Error/BadRequest" responseMode="ExecuteURL" statusCode="400"/>
    <error path="/Error/Unauthorized" responseMode="ExecuteURL" statusCode="401"/>
    <error path="/Error/Forbidden" responseMode="ExecuteURL" statusCode="403"/>
    <error path="/Error/NotFound" responseMode="ExecuteURL" statusCode="404"/>
    <error path="/Error/Gone" responseMode="ExecuteURL" statusCode="410"/>
    <error path="/Error/InternalError" responseMode="ExecuteURL" statusCode="500"/>
  </httpErrors>
  ...
</system.webServer>

Each path must exist as routable url, we have them as specific pages in the CMS

#299922
Edited, Apr 11, 2023 14:02
EVT
Vote:
 

But if we do not have this and yet somehow this works on two environments, where else could this be setup... (headache)

#299972
Apr 12, 2023 6:00
Vote:
 

Possibly related to environment specific config transforms, or even something as simple as you building with debug in dev and release to the other environments

#299973
Apr 12, 2023 6:24
EVT
Vote:
 

Finally we found it - it was in BaseAnyContentController method OnException we had an if clause "if (!Request.IsLocal)"

#301921
May 16, 2023 11:27
Vote:
 

The exact configuration for displaying custom error messages instead of the full stack trace on localhost depends on the web server platform you are using. Generally, it involves adding custom error pages and setting the appropriate HTTP status codes to indicate an error condition. For example, if you are using Apache, you can use the ErrorDocument directive in your .htaccess file to configure custom error pages. In some cases, you may need to make changes to the web.config file to properly configure custom error pages. The exact configuration settings will depend on your particular web server platform. Additionally, you may need to configure any errors that are not supported by the web server, such as 404 Not Found errors, manually.

#301969
May 17, 2023 13:45
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.