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="data source=sql.[somedomain].net;initial catalog=[mydatabase name];User ID=[myUsername];Password=[myPassword];MultipleActiveResultSets=True;App=EntityFramework"" 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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With