Search code examples
c#asp.netsql-serverweb-applicationsremote-server

Website in web hosting service and DB in local server


I have my webapp (ASP.NET) and database (SQL SERVER) on my own server. I plan on moving the website to a web hosting service like GoDaddy but I need to keep the database on my server. Is there a way to get a connection to my database and fetch data while my website is in the web hosting service?


Solution

  • If you host SQL Server and open up the right ports on your firewall, this could even work, but why do you want to do that? a SQL connection is not really designed to be established between differemt networks, it is going to be VERY slow.

    You are going to give yourself lots of issues to take care of, if the reason you do not want to host your database in the cloud is because you consider your data very sensitive, then you will need to encrypt the connection.

    Technically it is possible to do what you ask but is at least unusual as an approach, if you do not trust the hosting provider then change provider and keep data and web application together that simplifies lots of things, not to talk about inter data center latency issues...

    Another way you could get what you want would be to expose from your network not SQL server for incoming SQL connections, instead, make your data available via web services ( WCF or web apis ) and web app deployed elsewhere can pull data from these services with no need to connect directly to SQL server.