Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > having safe QueryStrings hyperlinks

Reply
Thread Tools

having safe QueryStrings hyperlinks

 
 
Pat
Guest
Posts: n/a
 
      09-02-2005
I have a link i.e http://puppy/ShowBlank.aspx?b_id=34
When a user click on the link above and gets to it its fine..
But i want to prevent the user from copying the link and pasting the link to
a new browser window
If they do that i want to return an error for example "you can't come to
this page through this link"
Any ideas


 
Reply With Quote
 
 
 
 
=?Utf-8?B?R2FyeSBL?=
Guest
Posts: n/a
 
      09-02-2005
Greetings & Salutations,

Try checking the Request.UrlReferrer property. If it does not correspond
with the page it's supposed to come from (and you could use an array of links
to check) then just reject the request (with appropriate error page message).

If the user cuts/pastes the link into a new browser window the referrer is a
blank string (I think, could be null).

Gary K

"Pat" wrote:

> I have a link i.e http://puppy/ShowBlank.aspx?b_id=34
> When a user click on the link above and gets to it its fine..
> But i want to prevent the user from copying the link and pasting the link to
> a new browser window
> If they do that i want to return an error for example "you can't come to
> this page through this link"
> Any ideas
>
>
>

 
Reply With Quote
 
 
 
 
Pat
Guest
Posts: n/a
 
      09-02-2005
Can you provide samples please

"Gary K" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Greetings & Salutations,
>
> Try checking the Request.UrlReferrer property. If it does not correspond
> with the page it's supposed to come from (and you could use an array of

links
> to check) then just reject the request (with appropriate error page

message).
>
> If the user cuts/pastes the link into a new browser window the referrer is

a
> blank string (I think, could be null).
>
> Gary K
>
> "Pat" wrote:
>
> > I have a link i.e http://puppy/ShowBlank.aspx?b_id=34
> > When a user click on the link above and gets to it its fine..
> > But i want to prevent the user from copying the link and pasting the

link to
> > a new browser window
> > If they do that i want to return an error for example "you can't come to
> > this page through this link"
> > Any ideas
> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?R2FyeSBL?=
Guest
Posts: n/a
 
      09-02-2005
I find it astonishing that you are a supposed programmer and you need samples
to access a class property, especially when there is plenty of free
documentation (c/ MSDN, TechNet, and that's just the official ones). You're
just lucky I'm in a generous mood today, Your Laziness.

The "UrlReferrer" property of the "HttpRequest" class (accessible through
"Page.Request") is itself a class ("Uri" class to be precise). This class
provides several properties to find out the various parts of the URL.

One thing to remember is that when there is no referrer, this property is
null/nothing.

Ooops, my generous mood is running out, so I'll just give you a couple
quickies.

if (Request.UrlReferrer==null) { /* no referrer */ }
if (Request.UrlReferrer.Host=="mydomain.com") { /* a page on my domain sent
this request */ }
if (Request.UrlReferrer.Host=="127.0.0.1") { /* the request came from this
ip address */ }

And since domains can come as either host/ip names then better check for
both (although if your site uses full urls for links you can get away with
just the host name check).

I'll leave it up to you to do further research on the other properties of
the "Uri" class.

Gary K

"Pat" wrote:

> Can you provide samples please
>
> "Gary K" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Greetings & Salutations,
> >
> > Try checking the Request.UrlReferrer property. If it does not correspond
> > with the page it's supposed to come from (and you could use an array of

> links
> > to check) then just reject the request (with appropriate error page

> message).
> >
> > If the user cuts/pastes the link into a new browser window the referrer is

> a
> > blank string (I think, could be null).
> >
> > Gary K
> >
> > "Pat" wrote:
> >
> > > I have a link i.e http://puppy/ShowBlank.aspx?b_id=34
> > > When a user click on the link above and gets to it its fine..
> > > But i want to prevent the user from copying the link and pasting the

> link to
> > > a new browser window
> > > If they do that i want to return an error for example "you can't come to
> > > this page through this link"
> > > Any ideas
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
naijacoder naijacoder
Guest
Posts: n/a
 
      09-02-2005
Very well thanks for your generosity.
I taught you had something you could just post to help.
I was lazy and i agree only becos it was something i had to do with
limited time which i did using another solution.
Thx


*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
=?Utf-8?B?R2FyeSBL?=
Guest
Posts: n/a
 
      09-04-2005
It's alright, I do apologise for the way I expressed my sentiments. It was a
bad day, I was getting similar request from my users, I really hate lazy
thinking, and it was much easier to slag off at a faceless post rather than
the boss.

"naijacoder naijacoder" wrote:

> Very well thanks for your generosity.
> I taught you had something you could just post to help.
> I was lazy and i agree only becos it was something i had to do with
> limited time which i did using another solution.
> Thx
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
streams and querystrings =?Utf-8?B?Sm9obiBIb3BwZXI=?= ASP .Net 2 01-21-2005 09:35 PM
URL rewriting and querystrings Anthony ASP .Net 1 10-26-2004 05:30 PM
TreevIew having hyperlinks in the submenu naija naija ASP .Net Web Controls 0 09-08-2004 03:25 AM
Securing/Encrypting QueryStrings Rob Meade ASP .Net 0 01-22-2004 01:34 PM
VB Code behind: Howto handle querystrings and requests ALPO ASP .Net 1 11-15-2003 09:30 PM



Advertisments