gpt4 book ai didi

c# - 无法访问ASPNETDB.mdf

转载 作者:太空宇宙 更新时间:2023-11-03 16:38:47 27 4
gpt4 key购买 nike

我在下面添加了对静态ROLES类的引用,以将角色分配给加入该网站的人员。当我按下JOIN ASP.Net控件上的按钮时,我测试了代码,并且应用程序挂起。当然,我立即尝试调试以查找问题,但我无法再访问SQL Express ASPNETDB.mdf-错误在下面列出。提前致谢。

**The code-behind in the Join.aspx file:**
public partial class Join : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MembershipUser loggedIn = Membership.GetUser();
if (loggedIn == null)
{
return;
}
else
{
Session["userName"] = loggedIn.UserName;
Roles.AddUserToRole(loggedIn.ToString(), "MEMBER");

}
}

}


错误消息:无法打开用户默认数据库。登录失败。用户“ SFP \ Susan”的登录失败。

网络配置:

<?xml version="1.0"?>

<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->

<configuration>
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
</appSettings>
<system.webServer>
<handlers>
<remove name="ChartImageHandler" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"
path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
</system.webServer>
<system.web>
<authorization>
<allow roles="ADMIN" />
<allow roles="MEMBER" />
<allow roles="GUEST" />
<allow roles="RESTAURANT" />
</authorization>
<roleManager enabled="true" />
<authentication mode="Forms" />
<httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
validate="false" />
</httpHandlers>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</controls>
</pages>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<connectionStrings>
<add name="FCGuideEntities" connectionString="metadata=res://*/FCGuide.csdl|res://*/FCGuide.ssdl|res://*/FCGuide.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;attachdbfilename=|DataDirectory|\FCGuide.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>


堆栈跟踪

无法打开用户默认数据库。登录失败。
用户“ SFP \ Susan”的登录失败。
说明:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。

异常详细信息:System.Data.SqlClient.SqlException:无法打开用户默认数据库。登录失败。
用户“ SFP \ Susan”的登录失败。

源错误:

第48行:restCity4.Text = FeaturedList4 [0] .CITY.CITY_NAME;
第49行:
第50行:MembershipUser登录了= Membership.GetUser();
第51行:if(loggedIn == null)
第52行:{

源文件:H:\ FCGuide \ FCGuide \ default.aspx.cs行:50

堆栈跟踪:

[SqlException(0x80131904):无法打开用户默认数据库。登录失败。
用户'SFP \ Susan'登录失败。]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException异常,布尔值breakConnection)+5064474
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()+234
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj)+2275
   System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(布尔enlistOK)+35
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo,String newPassword,Boolean ignoreSniOpenTimeout,TimeoutTimer timeout,SqlConnection owningObject)+183
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo,字符串newPassword,布尔型redirectedUserInstance,SqlConnection owningObject,SqlConnectionString connectionOptions,TimeoutTimer超时)+239
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject,TimeoutTimer超时,SqlConnectionString connectionOptions,String newPassword,布尔型redirectedUserInstance)+195
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity身份,SqlConnectionString connectionOptions,对象providerInfo,字符串newPassword,SqlConnection owningObject,布尔redirectedUserInstance)+232
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions选项,对象poolGroupProviderInfo,DbConnectionPool池,DbConnection owningConnection)+185
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection,DbConnectionPool池,DbConnectionOptions选项)+33
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)+524
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)+66
   System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)+479
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)+108
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection externalConnection,DbConnectionFactory connectionFactory)+126
   System.Data.SqlClient.SqlConnection.Open()+125
   System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext上下文,Boolean revertImpersonate)+95
   System.Web.DataAccess.SqlConnectionHelper.GetConnection(字符串connectionString,布尔型revertImpersonation)+206
   System.Web.Security.SqlMembershipProvider.GetUser(字符串用户名,布尔userIsOnline)+1169
   System.Web.Security.Membership.GetUser(字符串用户名,布尔userIsOnline)+63
   System.Web.Security.Membership.GetUser()+19
   H:\ FCGuide \ FCGuide \ default.aspx.cs:50中的FCGuide._default.Page_Load(Object sender,EventArgs e)
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,Object o,Object t,EventArgs e)+14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(对象发送者,EventArgs e)+35
   System.Web.UI.Control.OnLoad(EventArgs e)+91
   System.Web.UI.Control.LoadRecursive()+74
   System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)+2207

最佳答案

检查是否可以访问用户的默认数据库,并且该数据库中有用于登录的用户。您可以从SSMS检查什么是默认数据库。

关于c# - 无法访问ASPNETDB.mdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8279170/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com