Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法使用asp.net成员身份在Web服务器中登录到我的页面_C#_Asp.net_Asp.net Membership_Sql Server 2012_Asp.net Roles - Fatal编程技术网

C# 无法使用asp.net成员身份在Web服务器中登录到我的页面

C# 无法使用asp.net成员身份在Web服务器中登录到我的页面,c#,asp.net,asp.net-membership,sql-server-2012,asp.net-roles,C#,Asp.net,Asp.net Membership,Sql Server 2012,Asp.net Roles,我已经使用sqlProvider和asp.net登录控件登录到我的管理页面。我在aspMembershipProvider中创建了4个用户。我可以在本地主机中使用相同的凭据登录。现在,我已经上传了我的网站在BigRock域,但在那里我无法登录。我已经复制了数据库和所有的表。用户存在于aspnet\u成员资格表和asp\u用户表中。但我仍然无法登录。这是我的代码,我一直在尝试 Login.aspx.cs protected void Page_Load(object sender, EventAr

我已经使用sqlProvider和asp.net登录控件登录到我的管理页面。我在aspMembershipProvider中创建了4个用户。我可以在本地主机中使用相同的凭据登录。现在,我已经上传了我的网站在BigRock域,但在那里我无法登录。我已经复制了数据库和所有的表。用户存在于aspnet\u成员资格表和asp\u用户表中。但我仍然无法登录。这是我的代码,我一直在尝试

Login.aspx.cs

protected void Page_Load(object sender, EventArgs e)
    {
        if (this.IsPostBack)
            ViewState["LoginErrors"] = 0;
        FormsAuthentication.SignOut();



    }
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        if (Membership.ValidateUser(Login1.UserName, Login1.Password))
        {
            FormsAuthentication.SetAuthCookie(Login1.UserName, true);
            string message = "Welcome "+Login1.UserName + "!!!";
            string url = "Admin/Admin.aspx";
            string script = "window.onload = function(){ alert('";
            script += message;
            script += "');";
            script += "window.location = '";
            script += url;
            script += "'; }";
            ClientScript.RegisterStartupScript(this.GetType(), "Redirect", script, true);

            Login1.FailureText = "";

        }
        else
        {
            // Username/password are not valid...
            e.Authenticated = false;


        }
    }
这是我的web配置文件:

<membership defaultProvider="SqlProvider">
      <providers>
        <clear/>
        <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" 
         connectionStringName="ConnectionString" applicationName="" 
             enablePasswordRetrieval="false" enablePasswordReset="true" 
             requiresQuestionAndAnswer="false" requiresUniqueEmail="false" 
             passwordFormat="Hashed" maxInvalidPasswordAttempts="5" 
      minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="0"/>
      </providers>
    </membership>

在将站点上载到服务器时,是否需要配置任何内容。
如果需要更多详细信息,我将提供。我需要找到解决办法。

首先感谢@Yevgeniy.Chernobrivets和@Rajesh Kumar帮助我。正如他们所说,我需要在aspnet_Applications表中设置一个应用程序名。因此,我添加了上述详细信息,现在工作正常。

您在IIS中配置了表单身份验证吗?请尝试将以下部分添加到您的web.config中(更改web.config后不要忘记执行iisreset)@是的,彻诺布里韦。。我已添加但尚未添加,但每当我尝试使用admin.aspx输入url时,我的页面仍将重定向到登录页面。除非并直到成功登录,它将不会重定向到那里。我想这不是正确地接受证书。将显示登录错误。是否更改了虚拟路径?请参阅这篇关于applicationName参数的帖子:2200_applicationName_2200-property-when-configuring-ASP.NET-2.0-Membership-and-other-Providers.aspxAsp.NET成员资格提供程序与应用程序一起工作有一个表名“aspnet_Applications”。检查应用程序是否有一行,因为同一数据库可以为多个应用程序运行