5

I made ASP.NET MVC web application, uploaded the files, also the database, but I get the following error when browsing it.

The network path was not found

I'm using Entity Framework and this is the connection string in my web.config file

<connectionStrings>
    <add name="[mydatabase]Entities" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=sql.[somedomain].net;initial catalog=[mydatabase name];User ID=[myUsername];Password=[myPassword];MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

I've uploaded many websites using IP Address eg. xxx.xxx.x.xxx as data source, but this is the first time to use server name eg. sql.[somedomain].net -I cannot get the server ip-, so I'm not sure if this caused the error, or if I should make something special to make it work.

So, I'm asking if there is something I should do to use server name as data source, if not then what else may cause this error.

This answer doesn't really help.

Thanks in advance.

Update

If I ping the server sql.[somedomain].net, I get this result

Ping request could not find host sql.[somedomain].net. Please check the name and try again.

And if I nslookup it, I get this result

*** Unknown can't find sql.[somedomain].net: Non-existent domain

So does that mean -for sure- that the server is not accessible. And is there anything I can do beside contacting the hosting technical support?

Solved

It was the Hosting Provider error/misconfiguration. After 3 days of searching and contacting the customer support, they realized it was their issue. I'm leaving this question to tell future viewers to Host Only with reliable/well-known Hosting Providers no matter what.

Community
  • 1
  • 1
Ahmed
  • 511
  • 3
  • 6
  • 26
  • Can you actually access sql.[somedomain].net from the machine this running on? – Chris Pratt Aug 18 '15 at 18:31
  • @ChrisPratt I updated the question, is this what you meant? – Ahmed Aug 19 '15 at 09:15
  • Where is the webserver located in relation to `sql.[somedomain].net`? Is `sql.[somedomain].net` in a different physical location and does it allow remote connections? (I hope not). – CodeCaster Aug 19 '15 at 10:49
  • Your ping result said that you can't reach this server. You can try something else. Try to connect this server with MS Sql Management Studio with thos credentials which you provide in connection string. Then you will be 100% sure – Marcin Aug 19 '15 at 10:52
  • @CodeCaster I don't know if it's on a different physical location or not, since it's the hosting provider choice. – Ahmed Aug 19 '15 at 11:13
  • @Marcin When connecting using MS SQL Managment Studio, it gives me this error `Cannot connect to sql.[somedomain].net`. Also `The network path was not found`. – Ahmed Aug 19 '15 at 11:14
  • Mayby you forgot about port: `sql.[somedomain].net:8234` ? some port - 8234 is an example – Marcin Aug 19 '15 at 11:16
  • I contacted the technical support, and they said they don't allow remote access on database -for security issues they said- and that I should use `sql.[somedomain].net` in the connection string. – Ahmed Aug 19 '15 at 11:21
  • @Marcin check the accepted answer [here](http://stackoverflow.com/questions/5294721/how-to-specify-a-port-number-in-sql-server-connection-string) , and it's comments. They say that every instance is on a separate port, so no need for port when specifying instance name – Ahmed Aug 19 '15 at 11:34
  • I don't know, probably because of first part of address `sql.` port is unnecessary. I think that you should ask them for working connection string example. – Marcin Aug 19 '15 at 11:34
  • We are getting this with Azure :-( – MBen Jul 21 '16 at 19:56

2 Answers2

1

The info you got from tech support seems fairly contradictory. It's common to disable remote access for database servers, but if that's the case, then using the domain to connect doesn't really help you.

If you're trying to connect to this database from a published MVC project, residing with the same provider as supplies your database, then you should have no issues connecting as you're no longer "remote". However, unless your DNS is also hosted at the same provider, using the domain may make the connection appear remote, as it's going outside to come back in. The safest bet is to simply use the IP address of the database server in the connection string.

Also, pay attention to the IP address you have for the database server. If it's in the 10.* or 172.* range, it's a local IP, but if it's something else, it's most likely an outside IP address. Trying to connect to such an address, may also make the connection appear remote as you're going outside the network to come back in. Also, while disallowing remote access to a database server is a good idea, you can generally safely allow remote access to certain IPs. You most likely don't have control over that directly, but you can check with your provider to see if they can add an explicit rule for your web server's IP so that even if the connection is coming through as remote, it'll still work.

As far as working locally in development, you'll just have to use a local database. You may already have that covered, but your question wasn't entirely clear on that aspect.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
  • 1
    Thanks for the informative answer, the customer support made me doubt, but after your answer along with some more research, I was most certain that this error wasn't because of me. I contacted them again and they solved it today. I don't know what they did, but now the web application works perfectly, while using `sql.[somedomain].net` as the _data source_ – Ahmed Aug 20 '15 at 09:26
1

I also faced the same issue. I used the forward slash instead of back slash for instance name (clustername\instancename). Once I changed it to back slash. It worked fine.