Hide SQL connection error msg

Stefan Sturm asked on October 8, 2019 12:14

Hello,

even though we set the configuration (web.config) to not show any detailed error messages (production), we still see this message: "The application could not connect to the database..."

I tried custom error msg handling too but without any success.

<customErrors defaultRedirect="~/CMSMessages/error.aspx" mode="On">
  <error statusCode="404" redirect="~/CMSMessages/PageNotFound.aspx" />
  <error statusCode="500" redirect="~/CMSMessages/PageNotFound.aspx" /> (just for testing)
</customErrors>

So how can I turn of those message?

Kind regards Stefan

Correct Answer

Stefan Sturm answered on October 10, 2019 12:18

Thankyou Juraj.

I decidet to not change the Error.aspx.cs file due to possible problems when it comes to Kentico upgrades. Instead I simply changed the correspondig .resx entries.

  • general.connection.detailederrormessage
  • general.connection.errormessage
  • general.connection.errormessagetitle

It may happen that those entries also will be overwritten during Kentico upgrades but the impact seems less so i went this way.

Thanks Stefan

0 votesVote for this answer Unmark Correct answer

Recent Answers


Juraj Ondrus answered on October 8, 2019 13:29

Isn't it possible that in your config file is the CMSDisplayApplicationErrorMessages web.config key? Otherwise a general error should be displayed if the connection to the SQL server failed.

0 votesVote for this answer Mark as a Correct answer

Stefan Sturm answered on October 8, 2019 13:46

Well this key is already set to false like:

<add key="CMSDisplayApplicationErrorMessages" value="false" />

And the exact visisble message is:

The application could not connect to the database, please check the connection string in the web.config file and SQL server availability. * Original error: For more details add the following key into the

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on October 9, 2019 10:32

Ahh OK, so you want to hide also this connection error. In this case you need to modify the \CMS\CMSMessages\Error.aspx.cs file. In this file the connection error 500 is handled individually so you need to adjust the code or remove it entirely.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.