2

I'm trying to deploy an AspNet Core application on IIS on a Windows 10 machine. The application is the sample MVC app that ships with VS 2015, using Individual User Accounts. It uses a SQL database, hosted on LocalDB. But when I try to deploy it to IIS it can't access the database.

According to this link, I need Database Manager for IIS, but this download is for IIS 7. Does it still apply on IIS 10?

Is it possible to use the same database I'm using on Visual Studio (hosted on LocalDB)?

--- UPDATE ---

After a while a figured out how to set IIS to work on a Development environment. Now when I try to reach the database I get the following error:

SqlException: 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: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred.

I guess the LocalDB instance need some sort of configuration to work with IIS. How do I check if it's configured to allow remote connections?

rbasniak
  • 4,484
  • 11
  • 51
  • 100
  • 1
    Whats the actual error message and what do you do to make it happen? I'm sure its a config issue rather than a version issue. You could connect to a SQL 2000 database if you had the right connection string. – Nick.Mc Aug 17 '16 at 01:30
  • @Nick.McDermaid It does not give any error at all. The screen just goes blank when I click on anything that access the database. I'm assuming IIS can't access a LocalDB instance without some sort of configuration. But not sure, I'm totally new to IIS – rbasniak Aug 17 '16 at 01:35
  • 1
    There's a useful error somewhere and finding that is the first step to troubleshooting. In your browser, press `F12` and go to the network tab - anything there? What about the console tab? Does the URL change at all? You can also turn on IIS logging to help isolate the issue. – Nick.Mc Aug 17 '16 at 01:43
  • @Nick.McDermaid Updated the question. – rbasniak Aug 17 '16 at 13:19
  • 1
    You're doing all this on one PC right? The 'remote connections' suggestion is misleading - forget it. You first need to find the database connection string in the web.config and post it here. – Nick.Mc Aug 17 '16 at 22:36
  • 1
    If it's related to identity, then here is the same question: https://stackoverflow.com/questions/22737373/how-to-deploy-asp-net-mvc-4-application-using-localdb-to-local-iis-on-windows-7?rq=1 Also, do you mind telling me how you change IIS to development mode? – Jonathan Ma Aug 17 '16 at 22:38
  • 1
    Are you deploying it to IIS on a different machine? Do you want to use the db on your machine or deploy a copy of the DB on the IIS machine? – Nick.Mc Aug 17 '16 at 23:49
  • @Nick.McDermaid The connection string is the same I'm using on Visual Studio: Server=(localdb)\mssqllocaldb;Database=dbname;Trusted_Connection=True;MultipleActiveResultSets=true – rbasniak Aug 18 '16 at 00:50
  • @Nick.McDermaid I'm trying to deploy on same machine. It's just for debugging purposes, so I would like to use the same DB I'm using on Visual Studio. – rbasniak Aug 18 '16 at 00:53
  • @JonathanMa The question is related to MVC 4, I'm using MVC Core. If I change the Identity the pool doesn't even start anymore. – rbasniak Aug 18 '16 at 00:56
  • @JonathanMa On your published folder, open web.config and add an environment variable called "ASPNETCORE_ENVIRONMENT" and set the value to "Development". On this link you can see how to create variables on web.config: https://docs.asp.net/en/latest/hosting/aspnet-core-module.html – rbasniak Aug 18 '16 at 14:57

0 Answers0