• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

change the directed page of RedirectFromLoinPage(username, createPersistentCookie)

Hello,
This is probably an easy question, but I don't know how it's done haha..
I have 2 web forms.

1. login.aspx
2. srecords.aspx

 in login.aspx i use form authentication.
in the code behind for the login, once i reach a point where the correct username and password are varified, i do RedirectFromLoinPage(txtUsername, False) and it transfers me to default.aspx (by default, default.aspx does not exist).

QUESTION: what do I need to do to change the page it directs me to.
it transfers me to default.aspx, and I want it to take me to srecords.aspx

thanks
0
avikatz16
Asked:
avikatz16
  • 4
  • 3
1 Solution
 
burakiewiczCommented:
FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, False)
Response.Redirect("srecords.aspx")
0
 
tusharashahCommented:
Put Response.Redier right after RedierFromLoginPage....

FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, False)
Response.Redirect("sRecords.aspx")

-tushar
0
 
avikatz16Author Commented:
burakiewicz could yo help me out or somebody,
every page i'm trying to access i get redirected to the login form.
i don't want that. i only want an assosiaction between login.aspx and srecords.aspx
in other words, it should only direct me to login.aspx if i'm trying to access srecords without getting authorized

thanks
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
burakiewiczCommented:
under you web.config for the authentication node you shld have something like

   
 <authentication mode="Forms">
    <forms name=".ASPXAUTH">
    path="/" loginurl="login.aspx"
    protection="All"
    timeout="30">
    </forms>
    </authentication>
then on the pages you want them to be restricted put this in the form load

 If User.Identity.IsAuthenticated Then
            lblUsrMsg.Text = "Welcome to the website"
         
        Else
            Response.Redirect("login.aspx")
        End If
0
 
avikatz16Author Commented:
in my Web.config file there is no closing tag </authentication>
the openning tag is             <authentication mode="Forms" /> and that's all there is to it right now.
the code above is bad. what goes where? you have open brackets .

also
.
.
.
 If User.Identity.IsAuthenticated Then
        ----->>   all website codebehind goes HERE?
         
        Else

        ----->>   ''''else if user is unauthorized?

            Response.Redirect("login.aspx")
        End If
0
 
burakiewiczCommented:
the code is not bad just learn to read  

<authentication mode="Forms" /> is a self closing tag that is why there is no </authentication>
  replace <authentication mode="Forms" />  with this<authentication mode="Forms">
    <forms name=".ASPXAUTH">
    path="/" loginurl="login.aspx"
    protection="All"
    timeout="30">
    </forms>
    </authentication>

If User.Identity.IsAuthenticated Then
'user is authenticated show code for website, or nothing and it will load the web page
   lblUsrMsg.Text = "Welcome to the website"
 Else
'user is not authenticated, return to login page
            Response.Redirect("login.aspx")
        End If

0
 
avikatz16Author Commented:
burakiewicz , you're right your code was good, but I still haven't figured this out.
Before I made the changes above it still did the same thing it does now (after the changes above were made). the problem is that it restricts all the forms in the project and directs them to the login page. I only want this to happen to 1 or 2 forms, not all. what should I do?

thanks in advance,
i appreciate it
0
 
burakiewiczCommented:
the only other thing i have is

Imports System.Web.Security
at the top of the pages i have restricted, if that doesn't work, post some of your login code, and some samples
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now