ASP.NET Web アプリケーションに NHibernate、Persistence API、および MYSql DB を使用しています。そして、次の nhibernate マッピング ファイルがあります。
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="JPUMain" transaction-type="RESOURCE_LOCAL">
<provider>NPersistence.NHibernate.NHibernatePersistence</provider>
<class>JDAL.Impl.Entities.Answer</class>
<properties>
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="connection.connection_string">Database=DBName;Data Source=localhost;User Id=root;Password=;Charset=utf8;</property>
<property name="dialect">NHibernate.Dialect.MySQLDialect</property>
<property name="query.substitutions">true=1;false=0</property>
<property name="connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
<property name="show_sql" value="true"/>
<property name="hbm2ddl.keywords" value="none"/>
<property name="hbm2ddl.auto" value="validate"/>
</properties>
</persistence-unit>
</persistence>
現在、ASP.NET ログイン コントロールを使用してログインしています。ログイン ページで無効な資格情報を提供すると、他のページにリダイレクトされず、サーバー側でコードを処理した後、ログイン ページ自体にエラー メッセージが表示されることが予想されます。コードをデバッグしましたが、サーバー側の処理は問題ないように見えますが、ログイン資格情報が適切かどうかを検証するサーバー側のメソッドを実行した後、Web サイトがハングします。タイムアウト期間が経過すると、次のエラー メッセージが表示されます。
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
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.
SQLExpress database file auto-creation error:
The connection string specifies a local Sql Server Express instance using a database location within the application's App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:
If the application is running on either Windows 7 or Windows Server 2008R2, special configuration steps are necessary to enable automatic creation of the provider database. Additional information is available at: http://go.microsoft.com/fwlink/?LinkId=160102. If the application's App_Data directory does not already exist, the web server account must have read and write access to the application's directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist.
If the application's App_Data directory already exists, the web server account only requires read and write access to the application's App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the application's App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server account's credentials are used when creating the new database.
Sql Server Express must be installed on the machine.
The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.
私の最初の質問は、なぜ SQL Server に接続しようとしているのかということです。アプリのどこにも SQL Server を使用していません。
そして私の 2 番目の質問は、有効な資格情報を提供すると、それらが検証され、次のページに正常にリダイレクトされるため、正常に機能することです。また、無効な資格情報を提供すると、サーバー側の方法を処理して資格情報を適切に検証しますが、その後ハングします。
誰でもこれに光を当てることができますか?