locked
trouble deploying to web host RRS feed

  • Question

  • User759549661 posted

    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:

    1. Am I in the right kind of plan for this kind of application? Do I really need a VPN plan?
    2. Is it really not possible to authorize my databases on the website without creating them manually in Plesk, in a shared hosting plan?
    3. 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

    Thursday, February 7, 2019 10:11 PM

Answers

  • User759549661 posted

    In my opinion, you mix the application and the sql database.

    Thanks for the helpful input, Brando! You are right, I was imagining that the SQL server capability of the host should be able to see the databases that were uploaded when I did the Publish. The host plan does feature MSSQL (SQL server 2016) databases (up to 5), so I think the capability is there, but as you say, it is a separate service, which is accessed via Plesk. 

    I have found out, however, that a shared hosting plan should work, because it IS possible to upload my databases to the SQL server: see:

    https://support.hostgator.com/articles/plesk/windows-shared-hosting-information/how-to-import-a-mssql-database-windows-share

    Hostgator is not my hosting company, but my company tech support says they prefer this to be done via importing a database dump in Plesk:

    Websites & Domains > Databases > Import Dump

    Now I just need to make backup copies of my .mdf files in the dump (zip) format, that can be imported. I will try SSMS for that, but if there is a better way to go, please let me know!

    Rob

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, February 9, 2019 5:11 PM

All replies

  • User283571144 posted

    Hi MPT79,

    In my opinion, you mix the application and the sql database.

    You should understand we need a service(like IIS) to host the application and need a service(like sql server )to host the sql database.

    If the server doesn't contains the sql server you will face this issue.

    • Am I in the right kind of plan for this kind of application? Do I really need a VPN plan?

    In my opinion, this is related with the host environment.  If your host environment could install the sql server. Then you could directly install it and use its connection string in your application.

    If the host environment couldn't install the sql serve and you don't have another service like azure sql database to run your database, you should use VPN to connect to special server which running a sql server.

    • Is it really not possible to authorize my databases on the website without creating them manually in Plesk, in a shared hosting plan?

    This issue is related with the Plesk, you should connect to the Plesk supporter to ask for details information.

    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?

    You should make sure your server has the sql server to get the AttachDBFileName and then you should make sure the path is right in the connection string.

    Normally, the connection string format is as below:

    Server=myServerAddress;Database=myDataBase;User Id=myUsername;
    Password=myPassword;

    We don't directly use  AttachDBFileName with mdf file in the connection string.Using AttachDBFileName and User Instance means that SQL Server is creating a special copy of that database file for use by your program. If you have two different programs using that same connection string, they get two entirely different copies of the database. This leads to a *lot* of confusion, as people will test updating data with their program, then connect to a different copy of their database in Management Studio, and complain that their update isn't working.

    Best Regards,

    Brando

    Friday, February 8, 2019 7:50 AM
  • User759549661 posted

    In my opinion, you mix the application and the sql database.

    Thanks for the helpful input, Brando! You are right, I was imagining that the SQL server capability of the host should be able to see the databases that were uploaded when I did the Publish. The host plan does feature MSSQL (SQL server 2016) databases (up to 5), so I think the capability is there, but as you say, it is a separate service, which is accessed via Plesk. 

    I have found out, however, that a shared hosting plan should work, because it IS possible to upload my databases to the SQL server: see:

    https://support.hostgator.com/articles/plesk/windows-shared-hosting-information/how-to-import-a-mssql-database-windows-share

    Hostgator is not my hosting company, but my company tech support says they prefer this to be done via importing a database dump in Plesk:

    Websites & Domains > Databases > Import Dump

    Now I just need to make backup copies of my .mdf files in the dump (zip) format, that can be imported. I will try SSMS for that, but if there is a better way to go, please let me know!

    Rob

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, February 9, 2019 5:11 PM