使用其他服务登录?

时间:2016-05-14 04:47:56

标签: c# asp.net authentication web webforms

我在asp.net(visual studio v 2015)中有web表单应用程序,我使用提供程序类文件(我的提供程序),并创建一个本地Web配置,并在主web.config中添加代码,如blow,for重定向用户而不登录"登录页面",但是当我运行项目时,应用程序显示默认的visual studio登录页面(不是我的登录页面),如附件,请帮助。

  

错误:

     

使用其他服务登录。没有外部身份验证   配置的服务。有关设置此内容的详细信息,请参阅此文章   ASP.NET应用程序,支持通过外部服务登录。

我的提供者(cs文件)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;

namespace WebApplication3
{
    public class MyProvider : RoleProvider
    {
        Models.DB_NewsEntities db1 = new Models.DB_NewsEntities();
        public override string ApplicationName
        {
            get
            {
                throw new NotImplementedException();
            }

            set
            {
                throw new NotImplementedException();
            }
        }

        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override void CreateRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            throw new NotImplementedException();
        }

        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            throw new NotImplementedException();
        }

        public override string[] GetAllRoles()
        {
            throw new NotImplementedException();
        }

        public override string[] GetRolesForUser(string username)
        {
            int userID = int.Parse(username);

            var result = (from u in db1.Tbl_User join r in db1.Tbl_Role on u.RoleId equals r.RoleID where u.UserId == userID select r.RoleName).ToArray();

            return result;

        }

        public override string[] GetUsersInRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool IsUserInRole(string username, string roleName)
        {
            throw new NotImplementedException();
        }

        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override bool RoleExists(string roleName)
        {
            throw new NotImplementedException();
        }
    }
}

main web.confige添加了代码:

 <add key="ValidationSettings:UnobtrusiveValidationMode" value="none"/>


<authentication mode="Forms">
        <forms name="WebApplication3"  defaultUrl="/AdminPanel/WebForm1.aspx" loginUrl="/Login.aspx" />

    </authentication>

    <roleManager enabled="true" defaultProvider="MyProvider" >

       <providers>
          <clear/>
          <add name="MyProvider" type="WebApplication3.MyProvider"/>
       </providers>

    </roleManager>

本地web.config:

<pre lang="XML"><authorization>

  <allow roles="Admin"/>
  <deny users="*"/>

</authorization>

Error image

0 个答案:

没有答案