connects only in debug mode

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BeemerBiker
    New Member
    • Jul 2008
    • 87

    connects only in debug mode

    My asp.net app can connect to the sql server when running in debug mode, VS2008.

    It will not connect at the published location using
    Code:
    http://localhost/...default.aspx
    .etc

    Connection string
    Code:
    Data Source=SWRI16SQL1;Initial Catalog=training09;Integrated Security=SSPI;

    Error message at the connection "open" statement:

    Login failed for user ''. The user is not associated with a trusted SQL Server connection.

    Note that the "user" was empty ie: '' as shown above.

    The entire app worked fine and the web page could be accessed by anyone on my domain right up to the time I switched from AccessDataSourc e to SqlDataSource.

    Anyway, just wondering how to debug this. All the queries and reports actually work and the remote sql server responds with the correct data, but only if I had hit F5 (debug) in Visual Studio 2008. Obviously, no one can access it because they get that trusted SQL complaint and I also get the same complaint when using localhost

    best regards
  • BeemerBiker
    New Member
    • Jul 2008
    • 87

    #2
    aspnet account required for sql server to work?

    I am posting this here because I never got an answer on the IIs forum.

    I switched from access to ms sql for my asp.net program and I can only access the sql server when running my web app in debug mode on visual studio. I am (was) using Sql Express from Vs2005 and I put in the free Sql Studio. The database shows up just find in the database explorer and I can create tables, etc from the explorer or studio. If I publish to localhost and try to run my app then I cant make a sql connection. Our IT guy came in last friday to help me, but even he was stumped. We transfered the database to his sql server, and I reset the connection string to his but the same thing happened. It works fine in debug mode but not when published to my system.

    Error: "the user is not associated with a trusted SQL server connection" but this error is too generic and googleing I cannot find anything useful.



    Nothing like this ever happened on my other web app with postgresql on an external linux server so I assume it is some type of windows thing.

    I am building for dotnet 3.5 and running on an XP system that is up-to-date but am not using any dotnet 3.5 stuff.

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Hmm I haven't really had a lot of experience using Integrated Security before, so I'd be tempted to recommend that you should try using SQL Server Authentication instead of Windows Authentication.

      ASP.NET applications run under low trust levels and so you may have to use impersonation in order to use an account with enough permissions in order to connect to the database.

      I've found that Visual Studio uses the current user's permission levels (your account permissions) while debugging. IIS does not use your account, it uses the ASPNET account (or whatever they call it now, regardless it has low trust/security levels). So to get around this you're going to have to create a Windows User account that has the proper permissions to connect to the SQL server and have the ASP.NET application use this account (impersonation) to connect to the database.

      Comment

      • shressun
        New Member
        • Oct 2007
        • 1

        #4
        Not sure if you have resolved this. I think that you may have to modify your web.config to include impersonation. Came across this:



        Hope it helps

        Sunil

        Comment

        • BeemerBiker
          New Member
          • Jul 2008
          • 87

          #5
          Originally posted by shressun
          Not sure if you have resolved this. I think that you may have to modify your web.config to include impersonation. Came across this:



          Hope it helps

          Sunil
          Thanks for that link. I forwarded it to our IT staff. Last month, they did a lot of handwaving and googleing and announced that it was just my connection string. However, the connection string they gave me was the same one that didnt work the previous week when they started on my problem. When that same connection string did not work for a colleague, they got rid of windows authentication and went to sql authentication and "anonymous access" whatever that is. I have since retired so it is someone elses problem. Every engineer I talked with at work wants to use postgresql, mysql, and linux, and the IT staff is slowly losing its turf as it is stuck on windows.

          Comment

          Working...