无法访问ASPNETDB.mdf



我在下面添加了对静态ROLES类的引用,以将角色分配给加入网站的人。我测试了代码,当我按下JOINASP.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\SSusan"登录失败。

Web配置:

<?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>

STACK TRACE

无法打开用户默认数据库。登录失败。用户"SFP\SSusan"登录失败。描述:在执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误以及错误在代码中的来源的更多信息。

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

来源错误:

第48行:restCity4.Text=featuredList4[0]。CITY.CITY_NAME;第49行:第50行:MembershipUser loggedIn=Membership.GetUser((;第51行:if(loggedIn==null(第52行:{

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

堆栈跟踪:

[SqlException(0x80131904(:无法打开用户默认数据库。登录失败。用户"SFP\SSusan"登录失败。]System.Data.SqlClient.SqlInternalConnection.OnError(SqlException异常,布尔breakConnection(+5064474System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning((+234System.Data.SqlClient.TdsParser.Run(RunBehavior RunBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj(+2275System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(布尔登记OK(+35System.Data.SqlClient.SqlInternalConnectionTds.AttremptOneLogin(ServerInfo ServerInfo,String newPassword,布尔值ignoreSniOpenTimeout,TimeoutTimer timeout,SqlConnection owningObject(+183System.Data.SqlClient.SqlInternalConnectionTds.LoginoFailover(ServerInfo ServerInfo,String newPassword,布尔重定向的UserInstance,SqlConnection owningObject,SqlConnectionString connectionOptions,TimeoutTimer超时(+239System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginList(SqlConnection owningObject,TimeoutTimer timeout,SqlConnectionString connectionOptions,String newPassword,Boolean redirectedUserInstance(+195System.Data.SqlClient.SqlInternalConnectionTds.ctor(DbConnectionPoolIdentity标识、SqlConnectionString connectionOptions、Object providerInfo、String newPassword、SqlConnection owningObject、布尔重定向UserInstance(+232System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions选项,对象池GroupProviderInfo,DbConnectionPool池,DbConnection owningConnection(+185System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection、DbConnectionPool池、DbConnectionOptions选项(+33System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject(+524System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject(+66System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject(+479System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection(+108System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory(+126System.Data.SqlClient.SqlConnection.Open((+125System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext上下文,布尔revetImpersonate(+95System.Web.DataAccess.SqlConnectionHelper.GetConnection(字符串连接字符串,布尔值revertImpersonation(+206System.Web.Security.SqlMembershipProvider.GetUser(字符串用户名,布尔用户IsOnline(+1169System.Web.Security.Membersation.GetUser(字符串用户名,布尔用户IsOnline(+63System.Web.Security.Membersation.GetUser((+19FCGuide_违约H:\FCGuide\FCGuide\default.aspx中的Page_Load(Object sender,EventArgs e(。cs:50System.Web.Util.CaliHelper.EventArgFunctionCaller(IntPtr fp,Object o,Object t,EventArgs e(+14System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,EventArgs e(+35System.Web.UI.Control.OnLoad(EventArgs e(+91System.Web.UI.Control.LoadRecursive((+74System.Web.UI.Page.ProcessRequestMain(布尔型includeStagesBeforeSyncPoint,布尔型includeTagesAfterSyncPoint(+2207

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

我无法打开它,因为我有SQL2008,而数据库ASPNETDB.MDF实际上来自SQL2008-R2。在R2中打开它,然后从那里开始。

相关内容

  • 没有找到相关文章

最新更新