I have a asp.net MVC 4 that earlier works fine. Now when I run it I got error like
A non-recoverable error occurred during a database lookup
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.Net.Sockets.SocketException: A non-recoverable error occurred during a database lookup
Source Error:
Line 291: using (MySqlConnection cnn = new MySqlConnection(Globals.CONNSTRING))
Line 292: {
Line 293: cnn.Open();
Line 294:
Line 295: using (MySqlCommand cmd = cnn.CreateCommand())
I upload it on server and it's make crash of IIS on server. now every site on server is not working. can someone please tell me how to fix it?
This exception I got on my computer. When I visit to my site I see
Service Unavailable
HTTP Error 503. The service is unavailable.
Your database lookup can't be found...check the connection strings and make sure each part you have deployed shares the same connection logic :)
Related
I have an UWP application with an EFCore 2.1 datalayer which has to get data from a LocalDB, but I'm getting the following error:
Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related
or instance-specific error occurred while establishing a connection to
SQL Server. The server was not found or was not accessible. Verify
that the instance name is correct and that SQL Server is configured to
allow remote connections. (provider: SQL Network Interfaces, error: 50
Local Database Runtime error occurred. Unexpected error occurred inside a LocalDB instance API method call. See the Windows Application
event log for error details.
In the Windows Application event log, I have the following errors:
Windows API call CreateMutexW returned error code: 5. Windows system
error message is: Access is denied.
Unexpected error occurred while
trying to access the LocalDB instance registry configuration. See the
Windows Application event log for error details.
Windows API call
FormatMessageW returned error code: 1815. Windows system error message
is: The specified resource language ID cannot be found in the image
file.
Notes:
I can connect to the LocalDB with SSMS.
I have an API in .Net Core 3.1 which is using the exact same datalayer and connection string on the exact same LocalDB, but there's no error on this project and the data are correctly retrieved.
The UWP application can connect correctly to a SQL Server or SQL Express DB with also the same datalayer: only the connection string is changed.
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
Find place where this connection string is used and handle exception there.
I recently uploaded my data driven ASP.NET application to a asp hosting service called SmarterAsp.com.
Everything in the website works fine, all but 1 feature, data can't be entered into the database.
However when using a gridview control to see data in the database the data is displayed perfectly and I can even insert, update and delete data through the gridview.
I uploaded my database in a separate space on the hosting service and I was provided with a connection string, I replaced all connection strings in my application with the provided connection string.
It works fine in my IDE, the problem only came once I uploaded the website to the hosting service.
Here is my C# code for inserting data into my database:
protected void Button1_Click(object sender, EventArgs e)
{
using (SqlConnection connection = new SqlConnection(#DataSource=SQL5004.Smarterasp.net;Initial Catalog=DB_9DE115_hmkdatabase;User Id=DB_9DE115_hmkdatabase_admin;Password=YOUR_DB_PASSWORD;"))
{
SqlCommand cmd = new SqlCommand(#"INSERT INTO Clients(ClientName)VALUES(#ClientName)");
cmd.CommandType = CommandType.Text;
cmd.Connection = connection;
cmd.Parameters.AddWithValue("#ClientName", TextBox1.Text.ToString());
connection.Open();
cmd.ExecuteNonQuery();
}
}
And here is the error I get when attempting to insert the data:
Server Error in '/' Application.
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: SQL
Network Interfaces, error: 26 - Error Locating Server/Instance
Specified)
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: A network-related or
instance-specific error occurred while establishing a connection to
SQL Server. The server was not found or was not accessible. Verify
that the instance name is correct and that SQL Server is configured to
allow remote connections. (provider: SQL Network Interfaces, error: 26
- Error Locating Server/Instance Specified)
My first thought was that it's a problem with the connection string, but the connection string works fine with the rest of the application. I can enter data into my database through the gridview add function but I cannot enter data using the C# codebehind page. As I said it works fine in my IDE, the problem only came once I uploaded the website to the hosting service.
Thanks in advance for the help guys. You guys are real life heroes!
I sorted out the problem. My problem was where I initialized the connection string and where I opened the connection. I initialized the connection string at the top where the page is initialized. And then replaced where the connection string was with connection.open();
Thanks for all the help guys!
i'm developing an asp.net application. It's giving error. Any suggestions?
here is a portion of code behind:
// Authenticated, created session and API object
_connectSession = new ConnectSession(ApplicationKey, SecretKey);
if (!_connectSession.IsConnected())
{
// Not authenticated, proceed as usual.
}
else
{
// Authenticated, create API instance
_facebookAPI = new Api(_connectSession);
// Load user
user user = _facebookAPI.Users.GetInfo();
Here are details of the error:
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.Net.Sockets.SocketException: A socket operation was attempted to an unreachable host 69.63.176.141:80
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
thanks,
Gurbax Singh
Basically what the error is telling you is that the API couldn't connect to the Facebook API server at the specified IP address.
That IP for the Facebook API doesn't seem to be in use. Make sure you are using the latest versions of any Facebook API and that you look up the API server by hostname api.facebook.com
Currently I have it resolving to 69.63.181.46
More information available # http://forum.developers.facebook.net/viewtopic.php?id=50797
I'm making a webform that will go to a site, grab the rss feeds in xml format and read them into a XmlTextReader to be formated and displayed in my site.
I have this line which takes care of the reaching the other site
XmlTextReader reader = new XmlTextReader(#"http://www.wired.com/threatlevel/feed/");
When I run this from my localHost it runs fine. But once it gets publish on a 1and1 server it fails with the following error.
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 72.246.94.16:80
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.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 72.246.94.16:80
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Any ideas what can it be?
Many Thanks!
You're probably being blocked by an outbound firewall at 1&1.
Contact 1&1 and ask them to disable it, or switch to a better host. (you get what you pay for)