Hi All,
Using Visual Studio Express 2013 for Web I have developed an ASP.NET web forms application based on the Wingtip toys example, but with VB code. I have recently upgraded it to Visual Studio 2017. The application uses the ASP.NET identity database, and a
second database that contains product and customer information. My question relates to what kind of ASP.NET host I need to host the website, and how the databases can (should) be published, along with the rest of the application, in such a way that the application
can find them and use them.
Perhaps naively (and thinking that Azure was more than I needed), I signed up with a reputable ASP.NET provider with their most basic 1-website Windows shared hosting plan that supports ASP.NET 4.x, and published my application to the host using Web Deploy
with the “IIS, FTP, etc” option selected, expecting that, since the application worked fine in localhost, and publish was successful, that my website would work. I can see that all my files uploaded successfully in Plesk, including the two databases in the
App_Data folder.
But: I get a server error:
[Win32Exception (0x80004005): Access is denied]
[SqlException (0x80131904): 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: 56 - Unable to load the SQLUserInstance.dll from the location specified in the registry. Verify that the Local Database Runtime feature of SQL Server Express is properly installed.)]
If I go to the Settings tab in Publish and enter a path (given to me by tech support and including the database filenames) to the two databases in ApplicationDbContext and UserContext, and Publish, I get another server error:
[ArgumentException: Format of the initialization string does not conform to specification starting at index 0.]
My connection strings in Web.config that work for localhost are:
<add name="DefaultConnection" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Rob\Documents\Visual Studio 2013\Projects\LabEle3\LabEle3\App_Data\aspnet-LabEle3-20150324023533.mdf;Initial Catalog=aspnet-LabEle3-20150324023533;Integrated
Security=True" providerName="System.Data.SqlClient" />
<add name="LabEle3" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Rob\Documents\Visual Studio 2013\Projects\LabEle3\LabEle3\App_Data\LabEle3.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
But: even when I change the path in the connection strings to what should work on the server, I get these same errors when I Publish.
Tech support says that I need to add the databases via Plesk, in order for them to be recognized. This appears to involve a field-by-field recreation of each table. Or, at 5X the price, I could buy a VPN account that would allow me to upload already-existing
databases and register them and a user in Plesk from a command line via RDP. This all strikes me as odd, because a) I already have the databases on the website, inside the application, where they function just fine in localhost; b) I thought that one of the
features of ASP.NET was that the databases were managed from within the application, so that I ought to be able to set settings within the application that would allow the databases to be functional when uploaded during Publish; c) there is a “code first”
option in Publish Settings that is currently disabled, but could perhaps be enabled if I set up the application that way (?), that would use the T-SQL in the application to create the databases on-site (but would they then be accessible?); and d) I’m wary
of trying to reconstruct (especially) the default database that is used by ASP.NET identity in Plesk. So before I undertake such, I would like to know:
- Am I in the right kind of plan for this kind of application? Do I really need a VPN plan?
- Is it really not possible to authorize my databases on the website without creating them manually in Plesk, in a shared hosting plan?
- Should the application be able to find and use the databases that are already there, simply by replacing my local path (C:\Users\Rob\Documents\Visual Studio 2013\Projects\LabEle3\LabEle3\App_Data\LabEle3.mdf) with the C:\ path to LabEle3.mdf on the server,
in the Web.config connection strings? If not, what else is needed?
Guidance would be greatly appreciated!
MPT79