views:

348

answers:

1

I reach my login page with the parameter "returnUrl" set to the URL I was on. Then, I login via OpenID (DotNetOpenAuth), and call FormsAuthentication.RedirectFromLoginPage(). The login is successful, however I am not returned to the original page I was on.

I'm having the same problem on logout - when I log out I don't remain on the same page, even though the logout link contains the correct "returnUrl" parameter.

What am I doing wrong?

Here is the code snippet. I am returning EmptyResult() after the call to RedirectFromLoginPage, because I don't really know what to do (see this related question)

using (var relayingParty = new OpenIdRelyingParty())
{
    var response = relayingParty.GetResponse();

    if (response == null)
    {
        // Stage 2: user submitting Identifier
        var openId = Request.Form["openId"];
        relayingParty.CreateRequest(openId).RedirectToProvider();

        throw new Exception("Never gets here");
    }

    // Stage 3: OpenID Provider sending assertion response
    switch (response.Status)
    {
        case AuthenticationStatus.Authenticated:
            var claimedIdentifier = response.ClaimedIdentifier;
            var user = _userRepository.FindByOpenId(claimedIdentifier);
            if (user != null)
            {
                // login
                FormsAuthentication.RedirectFromLoginPage(user.Id.ToString(), false);
                return new EmptyResult();

                // TODO - http://stackoverflow.com/questions/1991710/understanding-redirections-in-asp-net-mvc
                // throw new Exception("Should never get here");
            }
        ...
A: 

This is a shot in the dark but I recently experienced some weirdness with login redirects because the anonymous user did not have rights to my scripts folder. This caused the redirecturl to point to a jquery script because that was the last address the user attempted to access without success.

Jamie Ide
I have no javascript in my site yet, and I have no reason to suspect a permission problem. I am experiencing this in the built-in web server that comes with Visual Studio (2010 beta 2).
ripper234