Assuming that SQL Server is installed, SQLExpress will work too, the following shows how to publish an application to a local file folder and make that accessible across the local network. It will also specify an instance of SQL Server, not the default LocalDb. I found this useful to quickly demo a prototype for managers and get their feedback using just the IIS on my computer and our local network. Note that the steps here open up the app to everyone on the network, so it would not be useful if confidential information were involved.
-
Create the connection string in Web.config123456<connectionStrings><add name="BookStoreDb"connectionString="Data Source=.\SQL2014; Initial Catalog=BookStore; Integrated Security=False;User Id=BookApp; password=Super5ecret"providerName="System.Data.SqlClient"/></connectionStrings>
-
Publish the app to a folder
-
Assign that folder a name in IIS
-
Share the folder with Everyone. Navigate to your folder location. Right click it and click Give Access To > Specific People… Select Everyone from the drop down list and click Add, then Share
-
Turn on ASP.NET 4.7 (if not already enabled)
-
Create a SQL Login & User with permissions. The username from the connection string needs to be created and granted access or you will be faced with an error: Login failed for user ‘Foo’. Oddly, I found that when using Windows Authentication, the username was the machine and not the user’s domain account.
Mapping the User Login should create a User for the DB as well.
And if it tells you that user you just made cannot login, check the SQL Log.
12345Date,Source,Severity,Message12/08/2018 16:28:13,Logon,Unknown,Login failed for user 'BookApp'.Reason: An attempt to login using SQL authentication failed.Server is configured for Windows authentication only.[CLIENT: <local machine>]
And continue to troubleshoot. -
Enable SQL Server Authentication if not on
- Now you can navigate to localhost/BookStore