0

I am working on a web application. Can someone help me to redirect after login using Response.Redirect I tried any solutions that i have seen on the internet but no solutions worked for me.

Cant fix this problem since I started 2 weeks ago.

public void checkSessionIfNull(string location) {
    try
    {
        location   = "../examples/login.html";
        if (HttpContext.Current.Session[AppUser] != null){
            HttpContext.Current.Response.RedirectPermanent(location,false);
             HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
        else{
            returntoLoginIfSessionisNull(HttpContext.Current.Session[AppUser]);
        }
    }catch (ThreadAbortException ex1){
        Console.WriteLine(ex1.Message.ToString());
    }catch (Exception ex) {
        Console.WriteLine(ex.Message.ToString());
    }
}

Thanks , Regardds

mjwills
  • 23,389
  • 6
  • 40
  • 63
Ban Tot
  • 367
  • 2
  • 9
  • a) When testing, **never** use `RedirectPermanent`. If you make a mistake, the browser will 'remember' the mistake for a long time. b) Are you **sure** the above code throws `ThreadAbortException`? Can you test it again to be sure? – mjwills Jul 23 '19 at 05:05
  • If you have a new question, create a new one. Don't edit this one. – mjwills Jul 23 '19 at 06:42

0 Answers0