Skip to content

Instantly share code, notes, and snippets.

@Phuseos
Created May 24, 2016 10:45
Show Gist options
  • Save Phuseos/8df8b66e6b9c8f6334f62b78339bd6b9 to your computer and use it in GitHub Desktop.
Save Phuseos/8df8b66e6b9c8f6334f62b78339bd6b9 to your computer and use it in GitHub Desktop.
String matching in current URL (C#)
protected void ahrefOut_Click(object sender, EventArgs e)
{//Logout button
//Get the current absolute URL of the ContentPlaceHolder
string AbsoluteURL = BodyContent.Page.Request.Url.AbsoluteUri;
//Set the string to search for in the URL
string strCheck = "Test";
//If the URL contains (part of) the string to check redirect to special login page
if (AbsoluteURL.Contains(strCheck))
Response.Redirect("LoginTest.aspx");
//Otherwise, redirect to standard login
else
Response.Redirect("Login.aspx");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment