user1206480
user1206480

Reputation: 1858

Web Api works locally but not on my test server

I am using the latest asp.net mvc 5 and web api 2. Everything works locally but when my web site is deployed to my test server, everything works except the web api. When a HttpGet call is made to the api I get a 500 Internal Server Error with an ExceptionMessage:

ExceptionMessage=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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

and an InnerException of::

ExceptionMessage=The network path was not found

What makes this especially weird is that I have another website on the same test server with web api that works perfectly. Because of the first above Exception Message, I was thinking that it might have something to do with the connection string, but assumed that it wouldn't be that since the new asp.net Identity 2.0 is utilizing it, and everything seems to be working in that regard. What am I missing here?

Upvotes: 1

Views: 3094

Answers (3)

Dharmender
Dharmender

Reputation: 1

So you are able to hit the service, the problem is connecting from service to your SQL server. Go to the applicationPool of your website. Change the Identity propery. Add the user who has access to your DB

Upvotes: 0

NullReference
NullReference

Reputation: 4484

It sounds like the connection string is wrong. Do you have access to remote desktop into the web server? If so try using the method below to create a test sql connection, just be sure to use the exact settings from you sql connection string.

http://blogs.msdn.com/b/farukcelik/archive/2007/12/31/basics-first-udl-test.aspx

Upvotes: 1

Toan Nguyen
Toan Nguyen

Reputation: 11591

CHeck the SQL connection string in your config, and make sure that it points to the correct database server

Upvotes: 0

Related Questions