vcbertini
asked on
Finding a word in a URL Referrer
This seems like it should be so simple, but is proving to be more difficult than I thought. Maybe I'm overanalyzing the problem. What I need to do is grab the referring URL, look for a specific word in that URL, then perform some actions based on those results.
For some reason, my code is not grabbing the proper word because it has ".aspx" tacked on to the end of it, so for example it's finding "Freshman.aspx" instead of just "Freshman" and then it's not processing the code properly. What can I do to fix that?
For some reason, my code is not grabbing the proper word because it has ".aspx" tacked on to the end of it, so for example it's finding "Freshman.aspx" instead of just "Freshman" and then it's not processing the code properly. What can I do to fix that?
if (HttpContext.Current.Request.UrlReferrer != null)
{
string itmReferrer = HttpContext.Current.Request.UrlReferrer.ToString();
words = itmReferrer.Split('/');
lblReferrer.Text = itmReferrer;
}
foreach (string word in words)
{
switch (word)
{
case "Freshman":
rblProgram.SelectedValue = "UG";
lblPageTitle.Text = "Freshman Application";
break;
case "Transfer":
bla bla bla
break;
}
}
Split it again on '.'.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This seemed to be the easiest solution for what I was trying to do. Thanks!