?
Solved

Finding a word in a URL Referrer

Posted on 2011-09-23
3
Medium Priority
?
192 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

764 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