How to set/update LoginUrl of form based authentication?

Last post 04-10-2008 8:19 AM by GLind. 10 replies.

Sort Posts:

  • How to set/update LoginUrl of form based authentication?

    02-18-2008, 6:19 PM
    • Member
      point Member
    • meetpravin123
    • Member since 10-10-2007, 12:21 PM
    • Posts 5

    Hi,

     I have created a web application in which i have two logins, for this I have two different login pages created, now my application is having one root web.config file where I can set the any one loginUrl, but what i can want it is, when user enters in the AREA1 then he should redirect to login page1 and when user enters in secure AREA2 then he should redirect to my second login page?

     

    how should i do this?

     

    any help to set or modify the loginUrl of form based authentication dynamically, is it possible or not?
     

  • Re: How to set/update LoginUrl of form based authentication?

    02-18-2008, 6:27 PM
    • Member
      505 point Member
    • annalady
    • Member since 05-08-2007, 2:15 PM
    • Posts 203

    Hi

    Sorry but you can't specify multiple loginUrl in you web.config

    What you should do is redirect the user to a specific login page using QueryString parameters

    Then you can manually authenticate your user using the FormsAuthentication.Authenticate("name", "password"); method

  • Re: How to set/update LoginUrl of form based authentication?

    02-18-2008, 6:40 PM
    • Participant
      1,994 point Participant
    • s10n
    • Member since 01-12-2007, 5:16 PM
    • El Salvador
    • Posts 425

    Create a web.config inside the folders that contain each one of your areas, this way you will be overriding the settings of your root web.config. 

  • Re: How to set/update LoginUrl of form based authentication?

    02-18-2008, 7:23 PM
    • Member
      505 point Member
    • annalady
    • Member since 05-08-2007, 2:15 PM
    • Posts 203

    I don't think that this will work

    But try it anyway, you never know...

  • Re: How to set/update LoginUrl of form based authentication?

    02-19-2008, 3:31 PM
    • Member
      point Member
    • meetpravin123
    • Member since 10-10-2007, 12:21 PM
    • Posts 5

    Yes, it will won't work because to put form based authentication in inside web.config we need to set that folder as a virtual directory in IIS, is there any other way as I also want to keep track of the page from where i redirected to the login page.

  • Re: How to set/update LoginUrl of form based authentication?

    02-23-2008, 1:02 PM
  • Re: How to set/update LoginUrl of form based authentication?

    04-10-2008, 2:56 AM
    • Member
      8 point Member
    • GLind
    • Member since 10-10-2007, 4:14 PM
    • Posts 4

    I got the same problem.

     Isn't there any solution for this problem?

  • Re: How to set/update LoginUrl of form based authentication?

    04-10-2008, 4:56 AM
    • Participant
      1,045 point Participant
    • srulyt
    • Member since 02-02-2008, 6:16 PM
    • Posts 226

    If its the same app and the same DB why not use one login and user roles?

    that is what user roles are for

    for more info check out the security tutorials on this site

    www.asp.net/learn/security

     

  • Re: How to set/update LoginUrl of form based authentication?

    04-10-2008, 5:19 AM
    • Member
      8 point Member
    • GLind
    • Member since 10-10-2007, 4:14 PM
    • Posts 4

    True, I have remaked the solution to one login.

     But I got one design for admin login and one for regular login?

  • Re: How to set/update LoginUrl of form based authentication?

    04-10-2008, 7:32 AM

     

    Actually u have not understood the problem. Instead of having 2 login controls what u can have is one login control and u can have user roles. If the logged in user is defined as "admin" role then u can show all the pages which is under the admin folder. but all the regular users will have access to have normal files. Articles about "roles" would give u a better picture.

     

     

    Jai Ganesh. J , GSD ,India

    Please Mark As Answer If my reply helped you.
  • Re: How to set/update LoginUrl of form based authentication?

    04-10-2008, 8:19 AM
    • Member
      8 point Member
    • GLind
    • Member since 10-10-2007, 4:14 PM
    • Posts 4

    I solved my problem via XiaoYong Dai code example: http://forums.asp.net/p/1216582/2167336.aspx#2167336

    Global.asax.cs:

    1            protected void Application_AuthenticateRequest(object sender, EventArgs e)
    2            {
    3                if (!Request.IsAuthenticated)
    4                {
    5                    if (Request.RawUrl.Contains("admin"))
    6                    {
    7                        Response.Redirect("~/Admin/Login.aspx");
    8                    } 
    9                }
    10           }
    
     
    This will make the subfolder access the /admin/login.aspx and default will access the /member/login.aspx from the loginUrl in authentication.
Page 1 of 1 (11 items)