Usha Raj

Usha Raj

  • NA
  • 144
  • 59.5k

Redirecting the page

Apr 7 2015 8:26 AM
I have a job applying page in my application,if we click on apply button it should be check the user is login or not ,if not it should be redirect to login page.
Generally after sign am redirecting to the home page but when we trying to apply the job ,it should not be redirect to home page,it should be job applying page after sign in,for this am writing the code to get the current page url and creating the session for that url, that session value am using in after sign in process like
 
protected void btnAp_Click(object sender, EventArgs e)
{
string path = HttpContext.Current.Request.Url.AbsolutePath; // here am getting the page url
path = path.TrimStart('/');
Session["pathUrl"] = path; 
int Id = Convert.ToInt32(Session["RegId"]);
if (Id != 0)
{
Response.Redirect("MyProfile.aspx");
}
else
{
Response.Redirect("SignIn.aspx");
}
}
 after sign in ,am writing the code like
 
 
protected void btnsignIn_Click1(object sender, EventArgs e)
{
string Email = txtemail.Text.Trim();
string password = txtpassword.Text;
int a = objsignin.SignIn(Email, password);
if (a !=0)
{
if (!string.IsNullOrEmpty(Session["pathUrl"] as string))
{
string urlToRedirect = Session["pathUrl"].ToString(); // if the user is login while applying the job then it should be redirect to job applying page or else home page
Response.Redirect(urlToRedirect);
}
else
{
Response.Redirect("HomePage.aspx");
}
}
else
{
lblmsg.Text = "Invalid Email/Password";
}
}
 
 Up to now ok,no issuess ,but am using two master pages for my application i.e after signinmaster page and before sign in master page,these two master pages contains with different menus,When I will try to apply the job it should check the user is logn in or not ,if not it should be redirect to sign page after sign it should be redirect to the job applying page with after sign in master page menu,so can any one tell me how to do this??
 
 

Answers (5)