Web App connecting to database using web.config file

I am using the web.config file to store my database connection string.  Everything was working fine when I was running to applicaiton on my local machine.  

However, when I deployed to the web I keep on getting this error:

System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) at System.Data.SqlClient.SqlConnection.Open() at Dev_verI.BasicSearch.BindList() in c:\inetpub\wwwroot\dev_veri\basicsearch.ascx.cs:line 104

The line it points to reads:
Before that I had set up the connection like this:

strConnection = ConfigurationSettings.AppSettings["ConnectionString"];
conn = new SqlConnection(strConnection);

The relevant information in my web.config file is:

<add key="ConnectionString" value="server = serverName;
Initial Catalog=dbname;integrated security=SSPI;
Connect Timeout=15;Network Library=dbmssocn;"/>

Any ideas why I'm getting this error?
Thanks for the help!
9/15/2004 9:51:56 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

6 Replies

Similar Articles

[PageSpeed] 21

Using this connection string, the application is trying to login to the SQL Server without providing any credentials.

You'll need to create a SQL Server user (not to be confused with Windows user accounts) and provide those credentials in the connection string (e.g. ...; user=aspnetuser; password=secret;...)

I have a blog.

Perhaps you'd like to read it.
9/15/2004 11:39:52 AM
In my application I'm using Windows authentication.  Any user that is a member of the group that is allowed to use my application is also a member of the group that has access to the SQL Server database.

Is there anyway I can use the windows authentication to specifiy the credentials?

9/15/2004 1:04:36 PM
There is a way using Impersonation.

What's happening at the moment is this:
When you make a request to an ASP.NET application, it is run under the ASP.NET account. You can, however, force the ASP.NET account to impersonate another user.
Unfortunately I'm not entirely sure how this is implemented, only that it is possible. A quick look through MSDN would probably tell you.
Sorry about that.
Good luck!

I have a blog.

Perhaps you'd like to read it.
9/15/2004 2:20:25 PM
you can use Impersonation but it is more logical to use a new user in sql server

for impersonation:
<identity impersonate="true"/>
9/15/2004 3:01:21 PM
I have set impersonation to true. 

Could the problem be that Anonymous Access is not turned off on the IIS server?

9/15/2004 3:20:39 PM
I don't thing so

Give necessary rights to the ASP.NET user on your database withh using Enterprise Manager
Scroll the databse and select Users
right click and select New Database User
Select <new> in Login Name combo
Select the ASPNET user from ... button
and on the Database Access tab check your database
I hope this solves your problem
9/16/2004 7:57:57 AM

Similar Artilces:

Why we use Web.Config File for connection string wether we can use class Library for get connection for whole web Application
 Why we use Web.Config File for connection string wether we can use class Library for get connection for whole web Application  please help me? Friend, Web.config has its own advantages. 1) Web.Config is used to store the important information like connections strings etc...so that it can be modified even after the code has been    deployed to the server without compiling the entire application again. 2) Since it is a XML file, there is no need of building the project of you are going to change the connection strings.   If you go for the class files,...

web web web
Name: bahadir Email: sensiz_olmuyor_t1_at_hotmail.com Product: Firefox 2 Beta 2 Summary: web web web Comments: web sayfası yapmak Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.8.1b2) Gecko/20060821 Firefox/2.0b2 ...

Using multiple web.configs with different web apps in the same web folder.
How do I tell a web application to use a specific web.config file instead of referencing the root web apps web.config file? Example: In IIS i have this setup:My Server  Web Sites     Default Web Site (this has web.config with a reference to a HTTP Handler)     My Http Handler           My Sub Web             < --- This sub web is looking for the http handler in this web hope that makes sense.   shawn use location elem...

How do I merge web services' app.config with web app's web.config? Help!!
I have a web application project that uses a separate class library containing web service references (service layer). I want to be able to configure the web reference URLs dynamically and I know you can set this up by setting the URL behavior to  'Dynamic', etc, etc. The problem is VS2005 puts the URLs in the project's app.config file. When the class library becomes a DLL component, I have no way of accessing the app.config file.Is there a way to make the web reference project to look for the URLs in the web.config instead of its app.config? Or is there a way to merge this app.config w...

Use web.config with web forms?
 Hi All, I'm doing some unit testing of a web application, and would like to use settings from a web.config file.  Is this possible? Thanks much,- Mark I'd suggest keeping your Unit Tests in a seperate project and using it's own .config file. It will be a little repetition but it will help to keep things seperated for perf and reusability without bloating your production app. I agree with Curt. It is better to seperate options for testing and release version. This will decrease the job to be done once the unit testing process is finished.Haissam Abdul Mal...

Using Multiple Web.Config for mutliple web apps sharing a web site as virtual directories
I have a web site on IIS 6.0 Windows 2003 Server. I have created several virtual directories to point to other .net projects that I wish to use in the website. The main site, which was made in C#, has a line in the web.config that allows the use of VB by defining a speical code directory. Now, when I attempt to use the other applications they throw this error. It looks like they are all sharing the main web.configParser Error Message: The code subdirectory '/Forum/App_Code/VBCode/' does not exist.Source Error: Line 62: <!-- for SIP asp.net forum -->Line 63: <codeSubDirect...

Need to put this in a web.config file. Transfer a collection from app.config to web.config.
<!--<setting name="Groups" serializeAs="Xml"> <value> <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <string>GL CA Corporate Data</string> <string>GL CONT Contractors</string> <string>GL IT SolutionDelivery</string> </ArrayOfString> </value> </setting>-->   I need to put this in the below web.config.<?xml version="1.0"?><!-- Note: As an alternative to hand editing this fi...

How to use a web user control from one web app in another web app?
I have a production web app project (at work) that has custom web user controls in it.I have another web app project for experimenting and I want to use some web controls from the production web app. The big trick is that I need to load the controls dynamically.LoadControl() doesn't seem to work - it complains about loading controls from a different application. I also tried adding a project reference to the production web app and using "UC1 newUC = new UC1();" and then "this.Controls.Add(newUC);", but the controls (like TextBoxes) on the web user control don't seem to exist on the new UC1s....

hei guys, i need help on my application, i'm using C#.NET as front-ed and SQL as back-end, aside from a datagrid, i want to display my data using textboxes and not a datagrid, i can do it using Visual Basic 6 but since i'm a newbee at C#.NET i don't know how to do it, specially the codes, can anyone help me with it? thank you in advance! If you are doing windows development, i would suggest using 'DataForm wizard' (Use Solution Explorer-->Rightclick project-->Add new Item-->New DataForm). It will guide you through steps. If you are doing web apps. Use quickstart to learn them. h...

Customize the published web.config file in a web app
We are a team developing an ASP.Net web app. We are facing the following situation: each development machine needs a slightly different web.config file. For example,each local developer machine.the continuous integration server.the open sandbox website.the production website.How do I customize the published web.config (through MSBuild for ex.). Does anyone has an idea on the matter? Thanks in advance,Joanneshttp://www.lokad.com   One possible solution is: - select one Web.Config (I usualy select development one) as a starting point - create XSLT files for any other Web.Con...

Reading Connection from Web Matrx Web.Config File
Hi, I am trying to read a database connection string from the web.config file as follows: <configuration>   <appSettings>       <add key="Dude" value="server=\'(local)\';trusted_connection=true;database=\'cte_surveySQL3\'"/>   </appSettings>  I would like to replace the connection string below with the value from the web.config file. Any help will accepted. System.Data.DataSet MyLoginMethod(string ti_email, string ti3_password, string districtID)         {     &n...

Run Vb.net Web app using Web Harpoon
Does anyone know what Begin Tag and End Tag to use to run a VB.Net web App in Web Harpoon? We are experiencing errors trying to run the app. Error --> The state information is invalid for this page and might be corrupted Thanks,   Erik...

How to use 2 web.config file in a single web application
Hello Guyz,In my web application I'm trying to use a Blog and for that I'm using the free version of community server. The blog itself runs fine. But I'm trying to use it as a subdomain of my original application.The blog itself has its own web.config file as my application does and for that it's throws the following  errorParser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS. It'...

one application has many web.config files which web.config file execute first?
hi to all In my application i will add three web.config file which will execute first. how to set it. Give me a guidlines. by Devan.G Hi,You can't add multiple web.config to applicationYou can add single web.config to each folder present in sub directories of your applicationYou can override the web.config files using multiple config files.SatalajWatch The true story of internet ||Yet another forum |||I'm big fan of Open source flash chart for .net very very simple I n t e r v i e w T i p s Hi, You can check this reference: http://www.beansoftware.com/ASP.NET-Tutorials/Mult...

Web resources about - Web App connecting to database using web.config file - asp.net.web-forms

Connecting rod - Wikipedia, the free encyclopedia
In a reciprocating piston engine , the connecting rod or conrod connects the piston to the crank or crankshaft . Together with the crank, they ...

COVER BOY: Dec. 15 Issue of ‘Time’ Features Mark Zuckerberg on Connecting the World
The cover of the Dec. 15 issue of Time features a familiar face — that of Facebook co-founder and CEO Mark Zuckerberg , the star of a long feature ...

Digital Media Wire - connecting people & knowledge —
dmwnews : Anomaly, the ambitious graphic novel by Brittenham and Haberlin, features augmented reality. http://bit.ly/Iwrxjr Already optioned ...

Connecting People to Brands and Products on Mobile
People come to Facebook not only to connect with friends and family but also with products and brands. Here's how we're making it easier to list ...

What stops users from connecting with an app through Facebook?
... This equals 850 million users who connect with apps using Facebook at a 59 percent conversion rate. About 590 million users back out of connecting ...

Home - WHLT 22 Connecting the Pine Belt Fan
Facebook is a social utility that connects people with friends and others who work, study and live around them. People use Facebook to keep up ...

US IT Staffing Recruiters Group - Connecting Ideas !
US IT Recruiter's Groups: IT Technical Recruitment. Its all about connecting to new Ideas !

Cold Christmas Bubbles - A Cool Connecting Dots Puzzle for Kids on the App Store on iTunes
Get Cold Christmas Bubbles - A Cool Connecting Dots Puzzle for Kids on the App Store. See screenshots and ratings, and read customer reviews. ...

Connecting a Relay to Arduino - Flickr - Photo Sharing!
Simple circuit to connect a 5V relay to one of the digital output pins of the Arduino. I drew this after a few threads showed up on the Arduino ...

Evidence Connecting Scott Roeder to Operation Rescue Found in Roder's Car - YouTube
Rachel Maddow unveils video evidence from KMBC TV in Kansas City of a note found in Scott Roeder's car at the time of his arrest for the murder ...

Resources last updated: 12/9/2015 11:35:00 AM