"The system cannot find the file specified"
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. text
Generally issues like this are related to any of the following need to be looked at:
- firewall settings from the web server to the database server
- connection string errors
- enable the appropriate protocol pipes/ tcp-ip
Try connecting to sql server with sql management server on the system that sql server is installed on and work from there. Pay attention to information in the errorlogs.
I got same error after publish my project to my physical server. My web application works perfectly on my computer when I compile on VS2013
. When I checked connection string on sql server manager, everything works perfect on server too. I also checked firewall (I switched it off). But still didn't work. I remotely try to connect database by SQL Manager with exactly same user/pass and instance name etc with protocol pipe/tcp and I saw that everything working normally. But when I try to open website I'm getting this error. Is there anyone know 4th option for fix this problem?.
NOTE: My App: ASP.NET 4.5 (by VS2013)
, Server: Windows 2008 R2 64bit
, SQL: MS-SQL WEB 2012 SP1
Also other web applications works great at web browsers with their database on same server.
After one day suffering I found the solution of my issue:
First I checked all the logs and other details but i could find nothing. Suddenly I recognize that; when I try to use connection string which is connecting directly to published DB and run application on my computer by VS2013, I saw that it's connecting another database file. I checked local directories and I found it. ASP.NET Identity not using my connection string as I wrote in web.config file. And because of this VS2013 is creating or connecting a new database with the name "DefaultConnection.mdf" in App_Data folder. Then I found the solution, it was in IdentityModel.cs.
I changed code as this:
public class ApplicationUser : IdentityUser
{
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
//public ApplicationDbContext() : base("DefaultConnection") ---> this was original
public ApplicationDbContext() : base("<myConnectionStringNameInWebConfigFile>") //--> changed
{
}
}
So, after all, I re-builded and published my project and everything works fine now :)