Alright after working on a login page and completing it, the requirements for my project have changed. I am no longer using FormsAuthentication to see if someone is logged in. Instead I am putting a passcode as the query. If the passcode exists then I let them continue to the page. If it does not exist I need to redirect them to a page so that they can enter the passcode. But first I need to capture the returnurl. Everything I read says returnurl has to do with FormsAuthentication, so I cannot find out how to capture the returnurl. Any help please?

I think I figured out that you use Request.RawUrl, but now on my page load I am trying to redirect if passcode exists in the URl go ahead to the screen, if not go to the login screen. Here's my code and it just keeps looping.

protected void Page_Load(object sender, EventArgs e)
        {
            string eventAuid = Request.QueryString["eventAuid"];
            string passcode = Request.QueryString["passcode"];
            string returnUrl = Request.RawUrl;

            if (passcode != null)
                {
                    Response.Redirect("EditEventDetails.aspx?eventAuid=" + eventAuid + "&passcode=" + passcode);
                }
                else
                {
                    Response.Redirect("Login.aspx?returnUrl=" + returnUrl);
                }
            
        }

Help Please!!!!!

so wot's the problem bigguy..

while redirecting append the current page URL to after login.aspx

which is implemented in very good manner by Mr Jesi 525

but i'm kinda thinking it would be donkey work.

instead you can think of something like a page or some utility which handles all this stuff.

so you dont have to do this manually on every page..!

hope that would help !

I figured it out myself, thank you.

would you like to share which approach u have used..?

I was going in a continuous loop with this:

if (passcode != null)                {                    Response.Redirect("EditEventDetails.aspx?eventAuid=" + eventAuid + "&passcode=" + passcode);                }

So I removed that, and instead of trying to get the returnURL like this:

string returnUrl = Request.RawUrl;

I just hard coded the page with the URL and then add my querystring parameters at the login page before it was redirected back after the passcode was entered correctly. I only need to do it on two pages of my whole site, so it works for the two pages.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.