简体   繁体   中英

Unhandled exception in ASP web.config connectionString setting

I am running an ASP website and connect to a SQL database, very standard setup. The connection string details are held in the <connectionStrings> tag of the web.config file.

If the database username/password details are not correct, I get an YSOD unhandled exception notice. This is not at all surprising, but I would like to show a custom error page instead. However, I cannot seem to get the custom page to show using <customErrors> settings.

It seems an unhandled exception at the web.config level (for example the incorrect database connection string) means the application does not get as far as redirecting to the custom error page.

Any advice on how to handle this exception would be much appreciated. I understand if the exception happened on a particular page I can add a try / catch to catch it. I am not sure where/how I can handle this exception:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Login failed for user xxxxx

查找使用此连接字符串的位置并在那里处理异常。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM