locked
Internal server error cause by database connection in web.config file RRS feed

  • Question

  • User507642527 posted

    Hi all,

    I'm having an issue where the page I'm trying to create on Azure is simply showing the text: "The page cannot be displayed because an internal server error has occurred." I'm using the connection string provided by Azure with the only change being to the username and password. If I delete the connectionStrings block the page loads fine.

    Could somebody verify if I'm structuring the web.config file correctly? A Microsoft site I found regarding this showed everything inside the <connectionStrings> tags but didn't show where in the file they belong. I'm also not sure if the username and password are to be encapsulated in quotes or not.

    Cheers - It's my first time trying to do this.

    <?xml version="1.0" encoding="utf-8"?>
    
    <configuration>    
     <connectionStrings>
       <add name="PWDB"; connectionString="Server=tcp:prodwisedata.database.windows.net,1433;Initial Catalog=ProdWiseData;Persist Security Info=False;User ID='user';Password='password';MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"/>
     </connectionStrings>
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
        <customErrors mode="Off"/>
        
      </system.web>
    
    </configuration>

    Saturday, January 28, 2017 12:30 PM

Answers

  • User753101303 posted

    Hi,

    Remove the extra ; after the name attribute. If you have single quotes around the user name and password in your real connection string, remove them.

    If the config file is correct but the connection string is not, you should have a server side exception that should give some details (for example if the connection string is correct but your user id/password is wrong). It's easier to see fist what is the exact error you have rather than looking at your app and wondering which error it could cause.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 28, 2017 1:40 PM
  • User1169094377 posted

    Though I've not deployed on azure, But there are couple of errors

    1) you need colon : not ; to mention port

    2) as you ask no need for '' if there are no space in them .

    3) there is no provider "attribute" part  mentioned in your connection string

    <add name="nameofconnectionstring" connectionString="serverinfo" providerName="providernameforMSSQLorMYSQLorAny" />

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 28, 2017 5:57 PM

All replies

  • User-1315512054 posted

    Hello,

    You should check the connection string, as it seems that when try to connect you receive the error.

    Regards

    Saturday, January 28, 2017 1:02 PM
  • User753101303 posted

    Hi,

    Remove the extra ; after the name attribute. If you have single quotes around the user name and password in your real connection string, remove them.

    If the config file is correct but the connection string is not, you should have a server side exception that should give some details (for example if the connection string is correct but your user id/password is wrong). It's easier to see fist what is the exact error you have rather than looking at your app and wondering which error it could cause.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 28, 2017 1:40 PM
  • User1169094377 posted

    Though I've not deployed on azure, But there are couple of errors

    1) you need colon : not ; to mention port

    2) as you ask no need for '' if there are no space in them .

    3) there is no provider "attribute" part  mentioned in your connection string

    <add name="nameofconnectionstring" connectionString="serverinfo" providerName="providernameforMSSQLorMYSQLorAny" />

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 28, 2017 5:57 PM
  • User507642527 posted

    Thanks for the answers!

    I fixed those little syntax issues and the page is now operating as expected, I'm now moving onto the code where I'll actually use the database.

    I didn't add a provider name, the connection string was provided by Azure so I'm assuming it's not needed for this - I'll keep it in mind if I run into more trouble though.

    Sunday, January 29, 2017 11:15 AM