Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi,
i have web form application in asp.net (visual studio v 2015),and i use provider class file (My provider), and create a local web config , and adding the code in main web.config like blow , for redirect users without login to "login page", but when i run the project , application show the default visual studio login page (not my login page) , like attached file , help please .

Error :
Use another service to log in. There are no external authentication services configured. See this article for details on setting up this ASP.NET application to support logging in via external services.


my provider (cs file)

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();
        }
    }
}

</pre>


main web.confige added code :
 <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>


local web.config :

<pre lang="XML"><authorization>

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

</authorization>


What I have tried:

user without login redirect to my "login.aspx" page.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900