Question

I have the following ajax script on my Default.aspx page for login

$(document).ready(function () {
    $('#UserLogin').submit(function (e) {
        $.post("LoginApp.aspx?formpost=Login", { UserID: $("#UserID").val(),
            UPass: $("#UPass").val()
        },
        function (response) {
            if (response === "failed") {
                $("#ErrorDiv").html(response).show();
                // LocalStorage.set('Error', response);
            }
        });

        e.stopPropagation();
        return false;
    });
});

and the following FormAuth

 If Request.QueryString("formpost") = "Login" Then

    If App.LoginUser(Request.Form("UserID").Trim, Request.Form("UPass").Trim) Then

        FormsAuthentication.RedirectFromLoginPage(Request.Form("UserID").Trim, False)
        If Request.QueryString("ReturnUrl") <> "" Then
            Response.Redirect(Request.QueryString("returnUrl"))
        Else
            Try
                Response.Redirect("secured/")     
            Catch ex As Exception

            End Try

        End If
    Else
        Response.Write("failed")
    End If
Else

    Response.Redirect(".")

End If

the problem is Response.Redirect("secured/") is not working.

Any help will be appreciated.

Was it helpful?

Solution

You'll have to handle redirect from javascript. Since you're not doing a postback, server never gets full control over the page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top