Problem with deploying web application RRS feed

  • Question

  • User-1603248099 posted

    I am using Visual Web Develop 2010 Express and have got my website set up, however, I keep running into a problem when it comes to running my user database from the App_Code folder. My host doesn't support access to the folder for security reasons, so I've used the 'Publish to Provider' to generate an SQL Query and I've inserted it into my database via SQL Management Studio and all of the table data is there and ready to rock (even with user data from testing the site). I've gone into Web.Config to update the Connection String to link in the SQL server. 

    However, whenever I try to use any log in features on the site I keep getting an error page. From what I understand, I don't think I've missed anything, but I suspect there's a strong chance I have. I am using Heart Internet as a host (using a Shared Host) and I am uploaded via FTP as Web Deploy is not supported. The website runs and works, it just whenever I try to access the log in database to register or log in, that's when it errors out on me. 

    On the server I have my application pool on IIS set to 'Integrated' and the runtime version to v4.0

    Any ideas on what I could have missed?

    For reference, this is my web.config file with private information cut out:

    <?xml version="1.0" encoding="utf-8"?>
      For more information on how to configure your ASP.NET application, please visit
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        <roleManager enabled="true" />
        <compilation debug="true" targetFramework="4.0" />
        <authentication mode="Forms" />
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        <add name="PlayerDbContext" connectionString="Data Source=[source];Initial Catalog=[database];Persist Security Info=True;User ID=[id];Password=[password]"
          providerName="System.Data.SqlClient" />
      <location path="default.aspx">
          <httpRuntime requestValidationMode="2.0" />
      <location path="Authenticate/AddCharacter.aspx">
          <httpRuntime requestValidationMode="2.0" />

    Wednesday, April 30, 2014 2:07 PM


  • User-1603248099 posted

    Figured it out, there was a problem with my connection string. Updated it and it's all working fabulously now. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 1, 2014 2:18 PM

All replies

  • User-1603248099 posted

    I've just decided to test my application with the connectionstring on my localhost.

    My login controls all still seem to point to the database in App_Code. I assumed by changing my connection string in web.config this would stop it from using it. I can't think of any where else the connectionstring would be referenced. 

    Wednesday, April 30, 2014 2:54 PM
  • User-1603248099 posted

    Figured it out, there was a problem with my connection string. Updated it and it's all working fabulously now. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 1, 2014 2:18 PM
  • User-166373564 posted

    Hi BrynP,

    Figured it out, there was a problem with my connection string. Updated it and it's all working fabulously now. 

    Glad to hear that you have solved this issue by yourself, and it is very appreciated to share your solution to us, and welcome to post your question on asp.net forums in the future.

    Best regards


    Thursday, May 1, 2014 9:14 PM
  • User-1603248099 posted

    Cheers for the kind words.

    I can elaborate a little more on the solution if it helps anybody in the future - even if it's just the methodology of it. 

    Essentially as a I was using a database on my PC, I got my database onto the SQL server by using 'Publish to Provider' when right clicking on the Data Connection in Visual Studio and used the Query created and copied it, went into SQL Management Studio, logged into the database on my host and used 'New Query' and pasted it and performed the query, which created my tables for me. The next step I tried was to copy and paste the connection string in the properties from the Data Connection in Visual Studio to my online database and *that* was my mistake. I assumed because it connected in Visual Studio, it would connect on my site. 

    In testing my site I kept finding that an error page would appear. So I assumed I had missed something and searched high and low and as far as I perceived I had done nothing wrong. I tried testing the connection by running the website on my PC and create a new user just to see where it would end up - whether it would be my PC's database or the one on my host's server. I was puzzled when the new user turned up on my PC's database, as it doesn't make much sense as there wasn't a connection string to it and the connection string I had was connected to my online database. So I figured it must be declared some where secret and looked high and low to see if it *somehow* ninja'd itself somewhere. But almost tearing my hair out (I'm a metalhead, so there's a lot of it), I figured it was high-time to seek the infinite wisdom of fellow geeks (IE yourselves). But I remembered that debugging is my friend, though I often like to pretend I know better.

    I then turned of custom error handling by adding this code 

    <customErrors mode="Off"/>

    Into the <system.web> section of my code. 

    Then it came up with this error when I reran my site.

    "Format from the initialization string doesn't comply with specs beginning at index 0"

    And I looked at the jargon that it displayed and picked out a keyword, "ConnectionString", it appeared the issue was in my connection string. So I went to ConnectionString.com and went through some plausible looking strings and then figured a generic string might not do and that it's possible my host prefers a different type of connectionstring. I found such layout on my host's website...but that didn't work too, because it tried "provider=" at the start. But I experimented and tried different combinations. 

    It seemed I had made 2 vital errors:

    1 - I missed the semi-colon at the end of the connectionstring

    2 - I didn't need to declare a provider.

    Once making those two very simple changes, it all worked. 

    For referenced, this was the final bit of code:

    <add name="ApplicationServices" connectionString="Data Source=[server];Initial Catalog=[DatabaseName];User Id=[id];Password=[password];" />

    Of course, I did come across something else, which may help. in your global.asax, add the reference 'System.Configuration' and inside of the Init method use the line:

    throw new Exception(ConfigurationManager.ConnectionStrings["YourConnectionStringName"].ConnectionString); 

    I did that to see if I wasn't going crazy and finding the Connection String was defined elsewhere.

    Friday, May 2, 2014 1:30 PM