How to get file part of referer

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

Is there an easy way to get the page only from the referer?

For example, if I have:

c:\inetpub\wwwroot\development\staf2\jobSummaryList5DataGrid.aspx?Position=5I want to only get "jobSummaryList5DataGrid.aspx?Position=5".Thanks,Tom.
 
tshad said:
Is there an easy way to get the page only from the referer?

For example, if I have:

c:\inetpub\wwwroot\development\staf2\jobSummaryList5DataGrid.aspx?Position=5I want to only get "jobSummaryList5DataGrid.aspx?Position=5".Thanks,Tom.

You could do something like this:

string origurl = "c:\\blah\\blah\\blah\\jobsummarylist.aspx?position=5";
string[] urlarr = origurl.Split(new char[]{'\\'});
string url = urlarr[urlarr.Length-1];

// results in url = "jobsummarylist.aspx?position=5"

This is admittedly not the most beautiful code, and there are some
variables that are part of the Request object that you could also use.
But you asked about the string.... so there you are. =)

Lowell
 
Lowell Heddings said:
tshad said:
Is there an easy way to get the page only from the referer?

For example, if I have:


c:\inetpub\wwwroot\development\staf2\jobSummaryList5DataGrid.aspx?Position=5I
want to only get "jobSummaryList5DataGrid.aspx?Position=5".Thanks,Tom.

You could do something like this:

string origurl = "c:\\blah\\blah\\blah\\jobsummarylist.aspx?position=5";
string[] urlarr = origurl.Split(new char[]{'\\'});
string url = urlarr[urlarr.Length-1];

// results in url = "jobsummarylist.aspx?position=5"

This is admittedly not the most beautiful code, and there are some
variables that are part of the Request object that you could also use. But
you asked about the string.... so there you are. =)

What variables that are part of the Request object would get me just the
file name.

I was asking about the string as that was what was showing in the trace
window.

Thanks,

Tom.
 
Back
Top