1

msdnのチュートリアルを使用して、ビジュアルWeb開発者に自分のWebサイトでメンバーシップの役割と登録を設定しました。ローカルでは完全に機能しますが、サーバーにアップロードすると、次のページが表示されます。

"Server Error in '/' Application.
--------------------------------------------------------------------------------

Configuration Error 
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.

Source Error: 


[No relevant source lines]


Source File: machine.config    Line: 160 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016 "

なぜ私がこれを見ているのか、そして私がこれをどうやって修正するのか誰かが知っていますか?どんな助けでも大歓迎です。

ありがとうございました

バエル。

編集:

エラーメッセージの次の行を読んだ後、web.configファイルを確認しました:「接続名'LocalSqlServer'がアプリケーション構成に見つからなかったか、接続文字列が空です。」...そして次の要素が完全に空であることに気づきました:

<connectionStrings/>//これは空であるはずですか?そうでなければ、ここに何をすべきですか?エラーでは、それは空であってはならないことを意味します。また、LocalSqlServerをどこに配置すればよいかわかりません

最新の編集

DataSourceをLocalHostに変更した後、次のエラーが発生します。

Server Error in '/JTS' Application.
--------------------------------------------------------------------------------

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) 
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: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

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): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849015
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
   System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) +4862333
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +90
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +342
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +221
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +189
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +31
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +433
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
   System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +499
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +65
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117
   System.Data.SqlClient.SqlConnection.Open() +122
   System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +87
   System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +221
   System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate) +815
   System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +105
   System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved) +42
   System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password) +78
   System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +60
   System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +119
   System.Web.UI.WebControls.Login.AttemptLogin() +115
   System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +101
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927 
4

6 に答える 6

9

LocalSqlServerの追加されたconnectionStrings要素という名前の接続文字列があることを確認してくださいWeb.config

標準のASP.NETメンバーシップ/ロールプロバイダーを使用している場合、デフォルトでは次のように宣言されます。

<membership>
  <providers>
    <add
      name="AspNetSqlMembershipProvider"
      type="System.Web.Security.SqlMembershipProvider, ..."
      connectionStringName="LocalSqlServer" ...

これconnectionStringNameがこのエラーの原因である可能性があります。Membership / Role APIの使用を計画している場合は、のセクションに名前が付けられた接続文字列を追加するか、その値有効な(および既存の)接続文字列名になるように変更する必要があります。LocalSqlServer<connectionString>Web.configconnectionStringAttribute

于 2010-01-20T10:26:31.393 に答える
3

.Netメンバーシップロールプロバイダーをお持ちの場合は、最初にこのリンクを参照してください。

わからないと言ってからの説明

ネットメンバーシップロールプロバイダーは、「LocalSQLServer」を検索するように設定されています。これは、LocalSQLServerという名前の接続の詳細を提供するか、不要であると言う必要があることを意味します。あなたができることはあなたのweb.configファイルでその<connectionstrings>部分を見つけて行を追加することです:

<add name='LocalSqlServer' connectionString='Data Source=DBServerName;
Integrated Security=false;Initial Catalog=DBName;
User ID=DBLogin;Password=DBPassword' providerName='System.Data.SqlClient' />

DBServerNameをSQLdbサーバーアドオンに置き換え、DBNameをアドオンに付属のデータベース名に置き換え、DBLoginとPasswordをSQLアドオンに付属しているものに置き換える必要があります。

LocalSQLSeverを使用したくない場合は、次の方法で削除できます。

 <remove name='LocalSqlServer' />

プロパティの下のweb.configファイルにあります。次に、ロールプロバイダーの接続文字列名を使用する接続文字列名に変更します。したがって、既存の接続文字列をname='LocalSQLServer'に変更します。

于 2010-01-20T10:28:58.827 に答える
3

LocalSqlServerは、machine.configのデフォルトの接続文字列エントリです。app / web構成ファイルにはありませんが、常に存在します。

VisualStudioと共にインストールされたsqlexpressのローカルインスタンスを指します。

デフォルトでは、メンバーシッププロバイダーは、構成時に、app_dataフォルダーにローカルの.mdfファイルを作成します([すべてのファイルを表示]をクリックします)。このデータベースはプロビジョニングされています。

何らかの理由で別のデータベースを使用する場合は、aspnet_regsql.exeを使用してプロビジョニングする必要があります。これは、windows / microsoft.net / framework/2.0.xxxxディレクトリにあります。

コマンドラインからaspnet_regsql.exe/?を実行します。指示を取得します。

だから..これがあなたがこれらのエラーを受け取っている理由かもしれません。別のデータベースを使用したいが、メンバーシップセクションを編集して新しいデータベースを指すようにしたくない場合は、localSqlServerを削除してから、再度追加する必要があります。

または、別の接続を指すようにメンバーシップ要素を構成します。

いずれの場合も、開発中に使用しているVSによってプロビジョニングされたローカルユーザーインスタンス以外のPROVISIONEDデータベースと、それを指す接続文字列が必要です。

<connectionStrings>
  <remove name='LocalSqlServer' />
  <add name='LocalSqlServer' connectionString='Data Source=DBServerName;
    Integrated Security=false;Initial Catalog=DBName;
    User ID=DBLogin;Password=DBPassword' providerName='System.Data.SqlClient' />
</connectionStrings>

編集:あなたの質問を読み直してください:

問題は、ホストにSQLがないか、ユーザーインスタンスを許可していないことです。通常、ホストされているサイトでは、データベースを要求し、資格情報を取得したら、aspnet_regsql.exeを使用してそのデータベースをプロビジョニングします。この場合、新しいデータベースを指すようにweb.configのメンバーシップセクションを変更する必要があります。

hth

于 2010-01-26T23:16:33.703 に答える
0

MicrosoftSQLServerの名前付きパイプとTCP/IPを有効にする

于 2010-01-28T18:18:40.390 に答える
0

machine.configから接続文字列を取得している可能性があります。removeを使用するのではなく、これらを取り除く最も簡単な方法は、connectionstringsセクションでセルフクローズのclear要素を使用することです。

すぐに使用できるメンバーシッププロバイダーには、ローカル接続文字列エントリが必要です(新しいプロジェクトはデフォルトでこれを取得します)。新しいプロジェクトを作成し、そこからスワイプすることができます。

サーバーでは、SQLが正しくインストールされていることを確認し、サーバーの詳細と一致するように接続文字列を更新する必要があります。

于 2010-01-29T23:36:05.390 に答える
0

ASPNETユーザーが問題のフレームワークの構成ディレクトリへの読み取りアクセス権を持っていない場合に、このメッセージをよく目にします。キーの1つにファイルディレクティブがあり、フレームワークにはそれを読み取るためのアクセス権がありません(アクセス許可を介して、またはファイルが存在しないため)。

于 2010-01-29T23:39:40.063 に答える