0

I'm trying to host an app made in asp.net mvc 4. I've installed a virtual machine (Windows Server 2008) and then I've installed IIS server configured for that. I've got to deploy the app but logically I have a problem. My app uses SQL Server as database. So, when I try to log in to my app, the system is waiting until it shows me an error message. Logically I have not configured the database connection to handle data from the server. My question is, how do I have to configure from my IIS server in the virtual machine where I have hosted my app to connect to my SQL Server database?

Thanks!

H35am
  • 768
  • 2
  • 12
  • 32
  • 1
    Your question is not very clear (and you're using "logically" in an odd manner). But we need to know if your database is on the same VM or another machine? (Being on a VM has no effect on connecting to a database.) If remote you need to ensure you have connectivity from the web server to the database server (SQL Server configured for TCP/IP connections; the right ports opened on Firewalls, ...) – Richard Mar 17 '15 at 11:10
  • Sorry, i need to know the last one you say. My database is on the host machine, and im trying to connect from virtual machine to access it. I hope that i have explained the correct way. – Jaime Menendez Llana Mar 17 '15 at 11:29
  • My connection string now is: //SQLEXPRESS – Jaime Menendez Llana Mar 17 '15 at 11:30
  • Being on the host of the VM makes no difference: it is a remote connection. So ensure IIS Express has TCP.IP connectiveity enabled (and note the port). On the host's FireWall open that port to the VM. Then set your connection string to use that port on the host machine (last step is unnecessary if using the default port number). – Richard Mar 17 '15 at 11:40
  • i enable the TCP/IP connection and i open a rule on the firewall to allow connection to 1433 port. But the problem persists. Any idea? – Jaime Menendez Llana Mar 17 '15 at 11:42
  • At this point you've done the easy things: so 1. what exactly is the error you are getting? 2 double check each bit of network configuration, 3. what does a little test app (simple console ADO.NET wrapper around `select @@version` or something equally simple): what does that report? – Richard Mar 17 '15 at 12:57
  • It could be something with the permission of the users in database? What type of authenticacion i need in the IIS? Basic or Windows? – Jaime Menendez Llana Mar 20 '15 at 08:30
  • It could be, the exception's type and message property will tell you. Without this basic diagnostic information we're just guessing. – Richard Mar 20 '15 at 10:55
  • I dont know exactly the problem, because when I try to log in, the screen shows me "an error has occurred while processing your request" with no more information. I imagine is by the connection with the database. So i dont know what more to do working. – Jaime Menendez Llana Mar 20 '15 at 10:57
  • Either run locally or change the error reporting mode. – Richard Mar 20 '15 at 13:03
  • It missed add a new rule on the Firewall to open 1434 UDP port and another one to allow the SQL Server Engine. Thanks for the help. It works now!. – Jaime Menendez Llana Mar 22 '15 at 14:28

0 Answers0