I am use asp.net 2.0 with code behind file as the C#
i have question..It is...
i was created web site and it connect to the database(sql server),
at the development time there was no error occur...I could enter data,retrieve data,update data...
Then i publish my site...then i connect that site to the iis web server in my computer
then I browse site via iis server...
At that time this error is occur...
the error message is
Login failed for user 'HOME\ASPNET'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'HOME\ASPNET'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

how am i haddle this...Help me...

Recommended Answers

All 6 Replies

show me your web.config..

<?xml version="1.0"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
	<appSettings/>
	<connectionStrings>
		<add name="Adv" connectionString="Data Source=.;Initial Catalog=model;Integrated Security=True;User ID=sa;password = password123;"/>
		<add name="modelConnectionString" connectionString="Data Source=.;Initial Catalog=model;Integrated Security=True" providerName="System.Data.SqlClient"/>
		<add name="modelConnectionString2" connectionString="Data Source=.;Initial Catalog=model;Integrated Security=True" providerName="System.Data.SqlClient"/>
	</connectionStrings>
	<system.web>
    <!--<customErrors defaultRedirect="xxx.aspx" mode="On" />-->
    <sessionState timeout="300000"></sessionState>	
    <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
        -->
		<compilation debug="true">
			<assemblies>
				<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
				<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></assemblies></compilation>
		<!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
		<authentication mode="Windows"/>
		<!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
	</system.web>
</configuration>

here is my project web config file

The Error means that your connection string is not Correct. The Username aka user id has an invalid user. i see in your web config

<add name="Adv" connectionString="Data Source=.;Initial Catalog=model;Integrated Security=True;User ID=sa;password = password123;"/>

You still have a "." that indicates the default sql instance. the best Way to resolve your problem.

1) Go to SQl management Studio and Connect to the sql server with the credentials you supplied in the web config, if they don't work , then that's the problem. Sort that out.

2) After you have sorted the login problem on the Sql management studio , then go to your web config and change the Data Source value to something don't use a "." there, change the username and password to what you used when you logged into SQL management Studio.

3) Make sure the Database is Correct and save your web config and try again.

Hope it Helps

hi friends, Thanks for the replies
but question is still available...
because at the development time[what my web application] there is no error ...
that mean there is no error in connection string..
but after i publish my web site there is a error occur...i cant seek where is that exception goes...
The error message is
Server Error in '/finalEXE1' Application.

Login failed for user 'HOME\ASPNET'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'HOME\ASPNET'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[SqlException (0x80131904): Login failed for user 'HOME\ASPNET'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734963
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +628
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +359
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +496
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
AdDataBase.return_mianAds(String sql) +116
AdSQL.searching(String pCon, String pType, String pMake, String pModel, Int32 pPage) +703
buyAuto.returnAds(String pstate) +353
buyAuto.Page_Load(Object sender, EventArgs e) +332
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061


what am i do?...
please help me...

as i said above and as you have showed below

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'HOME\ASPNET'.

The user HOME\ASPNET does not have permissions to access the database and these might be a domain user and remember that the user that you have locally on your development machine, might not necessarily have the same permission on the deployed server.

The Problem still lies on the connection string and other parts that you did not mansion in your explanation of your problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.