Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bunnynut 128 posts 310 karma points
    Jan 12, 2015 @ 21:04
    Bunnynut
    0

    Unable to connect to database when hosting website in IIS

    Hi there,

    I have just installed a new instance of Umbraco 7, but i am unable to run the website in IIS. I get the following errormessage when browsing to the website:

    Cannot open database "<dbname>" requested by the login. The login failed.
    Login failed for user 'IIS APPPOOL\<apppoolname>'.

     

    I created a specific login and user for the database and used those credentials in the connectionstring which now looks like this:

    <add name="umbracoDbDSN" connectionString="server=<server_name>;database=<dbname>;user id=<username>;password=<password>" providerName="System.Data.SqlClient" />

    The weird thing is when i run the project from Visual Studio the website works and i can add pages and do everything i want, so the connectionstring is correct but when its running under IIS it doesnt.
    Has anybody else experienced this issue?


    Thanks in advance.


  • Jan Skovgaard 11257 posts 23497 karma points MVP 7x admin c-trib
    Jan 12, 2015 @ 21:39
    Jan Skovgaard
    0

    Hi Bunnynut

    That's weird - What approach did you take when installing Umbraco? Did you use nuget or a manual installation approach? And have you checked that you can access the database with the credentials provided using SQL server management studio for instance?

    What database version are you using? Is it MSSQL? What version of IIS are you using? And what version of the .NET framework are you using? Is it 4.5?

    /Jan

  • Bunnynut 128 posts 310 karma points
    Jan 12, 2015 @ 22:02
    Bunnynut
    0

    Hi Jan,

     

    Thank you for your reply.

    I installed Umbraco though Nuget.

    And i have actually logged in using the same credentials in SQL Management Studio 2014 using an MSSQL database and i am able to connect and run queries on the database.
    Im using IIS 8.5 and the website is running under .Net 4.5.

     

  • Jan Skovgaard 11257 posts 23497 karma points MVP 7x admin c-trib
    Jan 13, 2015 @ 05:52
    Jan Skovgaard
    0

    Hi Bunnynut

    Ok....hmm, perhaps that path to the database is wrong in your connectionstring in the web.config?

    /Jan

  • Bunnynut 128 posts 310 karma points
    Jan 13, 2015 @ 16:19
    Bunnynut
    0

    Yes the connectionstring is in the web.config.

    By the path to the database, you mean the value in servername?

    If the connectionstring is somehow incorrect, why am i able to connect and interact with the database when i run the website from Visual Studio?
    It seems that it is bypassing the UmbracoDSN when its running under IIS.

  • Jan Skovgaard 11257 posts 23497 karma points MVP 7x admin c-trib
    Jan 13, 2015 @ 16:33
    Jan Skovgaard
    0

    Hi Bunnynut

    Yeah, I'm not sure about why you're able to run it using Visual Studio but not from within the browser.

    Would it be possible for you to create a video so we can see the issue? Maybe that can give us a more clear idea about it.

    /Jan

  • Bunnynut 128 posts 310 karma points
    Jan 13, 2015 @ 22:07
    Bunnynut
    0

    I Could try that, but what is you want to see exactly? Just to be sure so i dont cast Scarlett Johansen for nothing.

  • Jan Skovgaard 11257 posts 23497 karma points MVP 7x admin c-trib
    Jan 14, 2015 @ 05:49
    Jan Skovgaard
    0

    Hi Bunnynut

    I just want to see what happens when you try to load the site outside of visual studio and when you load it from visual studio - The two scenarios that you have already described :)

    /Jan

  • John Palmer 69 posts 193 karma points
    Jan 14, 2015 @ 09:45
    John Palmer
    0

    Not too sure about your issue. But I guess it seems that the problem on your connection string. Could you please check it again?

  • Bunnynut 128 posts 310 karma points
    Jan 14, 2015 @ 13:47
    Bunnynut
    101

    Hi John,

    Ok, i seem to have fixed it.

    The connectionstring wasnt wrong, because when i ran the project from Visual Studio that connectionstring is used for the database.
    I have actually already set up half of my website that way, created documenttypes and content.
    The error message suggests that the user 'IIS Apppool\' is unable to login in to the database. But the connectionstring doesnt contain the name of the apppool but a specified SQL login set up for this website. So it seems that the issue was caused by some setting in IIS.
    While i was creating this post i thought of checking the connectionstring in IIS, which should be the same as the one in the web.config and it actually was. However in IIS the option 'use Windows Integrated Security' was selected, so i changed that and specified the credential for the login, which were already specified in the connectionstring. So now it works. I have never come across this issue before and i have created numerous websites.

    So this issue was resolved, thank you guys for your time!

    I have selected my own post as the solution for this issue, i hope that is ok. If not, let me know.

  • Jan Skovgaard 11257 posts 23497 karma points MVP 7x admin c-trib
    Jan 14, 2015 @ 13:57
    Jan Skovgaard
    0

    Hi Bunnynut

    Happy to see you managed to figure it out - it makes sense that it did not work when using integrated security...:)

    Have fun Umbracoing.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft