做了个小网站,在VS2010中按Ctrl+F5运行时一切正常,但是用IIS7配置以后,可以打开登录界面,但输入用户名和密码后提示登录失败。
出现的信息如下:
“/”应用程序中的服务器错误。
用户 'IIS APPPOOL\OASystem' 登录失败。
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 用户 'IIS APPPOOL\OASystem' 登录失败。
源错误:
行 44: {
行 45:
行 46: T_Message T_m = db.T_Message.First(m => m.Msg_Status == false && m.Msg_Receive == username);
行 47: return true;
行 48: }
|
源文件: e:\Programme\Web\OASystem\App_Code\MessagerManager.cs 行: 46
堆栈跟踪:
[SqlException (0x80131904): 用户 'IIS APPPOOL\OASystem' 登录失败。] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +6676046 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +810 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4403 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +84 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +55 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +368 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +6704814 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +6705315 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions) +610 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +1049 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +74 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions) +6707883 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions) +78 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +2192 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +116 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1012 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +6712511 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +152 System.Data.SqlClient.SqlConnection.Open() +229 System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user) +65 System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe() +38 System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode() +30 System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) +81 System.Data.Linq.Table`1.System.Linq.IQueryProvider.Execute(Expression expression) +50 System.Linq.Queryable.First(IQueryable`1 source, Expression`1 predicate) +490 MessagerManager.GetMessage(String username) in e:\Programme\Web\OASystem\App_Code\MessagerManager.cs:46 MasterPage.Page_Load(Object sender, EventArgs e) in e:\Programme\Web\OASystem\MasterPage.master.cs:19 System.Web.UI.Control.LoadRecursive() +71 System.Web.UI.Control.LoadRecursive() +190 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178 |
版本信息: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.18034
请问该怎么配置?还是我网页的代码写得有问题?
public static bool GetMessage(string username) { DataBaseDataContext db = new DataBaseDataContext(); try { T_Message T_m = db.T_Message.First(m => m.Msg_Status == false && m.Msg_Receive == username); return true; } catch (System.InvalidOperationException) { return false; } }
那段代码可能是出自这里的,但是既然直接调试的时候没有错我也就没有关心,没想到配置网站以后除了这个问题
代码应该没什么问题,主要问题在于发布的问题;
帮你搜索了一下,看看有没有帮助
http://www.cnblogs.com/longgel/archive/2010/05/13/1735010.html
非常感谢!
但还有问题,那篇文章下面的评论不是说这样是不安全的吗?按照评论里说的设置又不行了