Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to call response.redirect from my custom c# class

I am in the process of coding a web application with asp.net. The users enter their credentials and these are validated against the actual email address and password for authorization. I wrote some classes for processing these data (in a seperate .cs file).

public static class Login
{
    public static void LoginFirstTime(string Email, string Password)
    {
      //This method logs the user in for the first time after he has registered.
       Response.Redirect("UserPage.aspx", true);
      //After logging in, the user will be redirected to his personal page.
    }

}

However I seem not to be able to access the Response.Redirect() method from inside the Login class which is in the seperate cs file. (I can access it from inside the event handlers I wrote for the aspx page.) Does anyone have an idea? Thank you in advance for helping!

like image 351
Onat Tanriover Avatar asked Oct 26 '13 22:10

Onat Tanriover


1 Answers

first level :

using System.Web;

in next use this in your code :

 HttpContext.Current.Response.Redirect("UserPage.aspx");

hope helps you

like image 168
Ali Gh Avatar answered Nov 15 '22 13:11

Ali Gh