Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Finding a word in a URL Referrer

Posted on 2011-09-23
3
Medium Priority
?
194 Views
Last Modified: 2012-05-12
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?
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;
                    }
}

Open in new window

0
Comment
Question by:vcbertini
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36591520
Split it again on '.'.
0
 
LVL 21

Accepted Solution

by:
Craig Wagner earned 1000 total points
ID: 36592430
Why not just use the Contains method of the string?

if( itmReferrer.Contains("Freshman")
{
}
else if( itmReferrer.Contains("Transfer")
{
}
0
 

Author Closing Comment

by:vcbertini
ID: 36599556
This seemed to be the easiest solution for what I was trying to do. Thanks!
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question