How to get file part of referer

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.
 
L

Lowell Heddings

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
 
T

tshad

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top