Showing posts with label classic. Show all posts
Showing posts with label classic. Show all posts

Saturday, March 24, 2012

server variables

Are server variables the same in .net, as they were in classic asp? If not, does anyone know where I can obtain a list of the updated .net sv's?The HTTPRequest Class offers some of them see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttprequestmemberstopic.asp

or you can still use the Server Variables but use the above where you can.

Simon
thank you!

Server Variables

Hi - i'm trying to get my application to detect the user id the user is logging onto my application with.
In classic ASP it was easy
Request.ServerVariables("AUTH_USER")

but it just wont work for me in .net
I've tried...

Request.ServerVariables("AUTH_USER")

and

Request.ServerVariables.Item("AUTH_USER")

Neither of them work i get what appears to be a permissions problem
The error i get is "Request is not available in this context"
Then it says it cant show me teh source unless i set debug="true" - but i have in both page and web.config so i don't know what's going on there either!

Anyone?

CheersThe error is about the Request object itself. The rest of that statement doesn't matter until you can get access to Request. Request is available on any method within a Page or UserControl class. If your code is in another object, you can reference it with HttpContext.Current.Request.

Server Variables Question

I have a simple piece of code which is being difficult.
I have a web page (in classic asp) that will redirect to a login page if
they didn't come from that page.

Which means that they have to access my page via the login page.

The login page...which is done in asp.net and resides on a server will
be directed to a default page once logged in. On this default
page...there's a link to access my page which is on another server and
done in classic asp.
On my page I test to see if they came from the default page.
This is my code:
If request.servervariables("HTTP_REFERER") <>
"http://www.thedefaultpage.com" then
response.redirect "http://www.theloginpage.com"
end if

When I do a response.write request.servervariables("HTTP_REFERER") it
show up empty. Is there an issue with using server variables from an
aspx page to an asp page?

Thanks
Rob

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!Shouldn't that be :

If request.servervariables("HTTP_REFERER") <>
"http://www.yourserver.com/thedefaultpage.asp" then
response.redirect "http://www.yourserver.com/loginpage.aspx"
end if

?

Juan T. Llibre
ASP.NET MVP
===========
"Rob" <robert@.hotmail.com> wrote in message
news:ea4n6vABFHA.2076@.TK2MSFTNGP15.phx.gbl...
> I have a simple piece of code which is being difficult.
> I have a web page (in classic asp) that will redirect to a login page if
> they didn't come from that page.
> Which means that they have to access my page via the login page.
> The login page...which is done in asp.net and resides on a server will
> be directed to a default page once logged in. On this default
> page...there's a link to access my page which is on another server and
> done in classic asp.
> On my page I test to see if they came from the default page.
> This is my code:
> If request.servervariables("HTTP_REFERER") <>
> "http://www.thedefaultpage.com" then
> response.redirect "http://www.theloginpage.com"
> end if
> When I do a response.write request.servervariables("HTTP_REFERER") it
> show up empty. Is there an issue with using server variables from an
> aspx page to an asp page?
> Thanks
> Rob
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
You do realize, Rob, that if clients have bookmarked
any .aspx page in your asp.net server ( *not* on the
..asp server ) that HTTP_REFERER will be empty,
don't you ?

That would mean that the client wasn't referred from
your .asp page, yet they'd be allowed to view your
..aspx page without being re-directed.

Juan T. Llibre
ASP.NET MVP
===========
"Rob" <robert@.hotmail.com> wrote in message
news:OvV4KGBBFHA.2180@.TK2MSFTNGP12.phx.gbl...
> Ya, I tried that and I tried just the domain and neither of them worked.
> I wasn't sure exactly what path would be returned so I tried to display
> it on the page and it's an empty string.
> Rob
Ya, I tried that and I tried just the domain and neither of them worked.
I wasn't sure exactly what path would be returned so I tried to display
it on the page and it's an empty string.

Rob

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
also a lot of proxy server strip the HTTP_REFERER header

-- bruce (sqlwork.com)

"Juan T. Llibre" <nomailreplies@.nowhere.com> wrote in message
news:OhsWjWBBFHA.612@.TK2MSFTNGP09.phx.gbl...
| You do realize, Rob, that if clients have bookmarked
| any .aspx page in your asp.net server ( *not* on the
| .asp server ) that HTTP_REFERER will be empty,
| don't you ?
|
| That would mean that the client wasn't referred from
| your .asp page, yet they'd be allowed to view your
| .aspx page without being re-directed.
|
|
|
|
| Juan T. Llibre
| ASP.NET MVP
| ===========
| "Rob" <robert@.hotmail.com> wrote in message
| news:OvV4KGBBFHA.2180@.TK2MSFTNGP12.phx.gbl...
| >
| > Ya, I tried that and I tried just the domain and neither of them worked.
| > I wasn't sure exactly what path would be returned so I tried to display
| > it on the page and it's an empty string.
| >
| > Rob
|
|
Actually it's the other way around. They login to the aspx page and when
the click on the link on the default page, they go to my asp page.
They're also passing a querystring parameter on that link and I check
for that too.

I realize the bookmark issue and I'm checking to see if the querystring
is empty or if they were referred from the default page. That ensures
that they have to access my page through the login.aspx page.
I've ommited this part because I didn't think it was relevant. I just
can't see why it would show up as empty string when trying to retrieve
the value.

I did some testing on our own server and showing the value of
request.servervariables("HTTP_REFERER") was not a problem.

Thanks
Rob

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Is there any way of configuring the proxy server to not do that?

Rob

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
On Wed, 26 Jan 2005 18:38:09 -0800, Rob <robert@.hotmail.com> wrote:

>Actually it's the other way around. They login to the aspx page and when
>the click on the link on the default page, they go to my asp page.
>They're also passing a querystring parameter on that link and I check
>for that too.
>I realize the bookmark issue and I'm checking to see if the querystring
>is empty or if they were referred from the default page. That ensures
>that they have to access my page through the login.aspx page.
>I've ommited this part because I didn't think it was relevant. I just
>can't see why it would show up as empty string when trying to retrieve
>the value.
>I did some testing on our own server and showing the value of
>request.servervariables("HTTP_REFERER") was not a problem.
>Thanks
>Rob
>
>*** Sent via Developersdex http://www.developersdex.com ***
>Don't just participate in USENET...get rewarded for it!

Doesn't it also mean that with the correct faked referer details you
wouldn't have to log in?

I

--
Iain Norman | http://www.eliteforum.org
Does anyone know a better way of doing this? The client just wanted 2
things...that the user comes from the login page and that the guid that
is passed to me matches a field in another database where we keep their
contact information.

Worse case scenario is that someone fake's the referer and has to
register for an event where he would have to pay online for this guy.

ROb

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Sounds like you need to check two things here: 1) That they are coming from
the login page, and 2) That they have successfully logged in. If either one
of these criteria is false, they need to be sent back to the login page,
right?

I would think that once the user logs in successfully, you could store the
GUID in a session variable? Just perform a check on the first page that the
HTTP_REFERRER is correct and that they are logged in -- if so, set the
Session variable to the GUID on this page. On subsequent pages just check
that the Session variable exists and is set to the valid GUID (you can
either just check that the session variable actually exists, or for more
security check it's validity against the database).

That's how I'm understanding your question anyway... I wouldn't pass
confidential info. like a GUID via QueryString.

Thanks

"Rob" <robert@.hotmail.com> wrote in message
news:OBUJOcgBFHA.2608@.TK2MSFTNGP10.phx.gbl...
> Does anyone know a better way of doing this? The client just wanted 2
> things...that the user comes from the login page and that the guid that
> is passed to me matches a field in another database where we keep their
> contact information.
> Worse case scenario is that someone fake's the referer and has to
> register for an event where he would have to pay online for this guy.
> ROb
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
Ya Michael, you're exactly right. However I'm limited in what I can do.
Our company is doing business with another company and they don't want
us to access their servers and this is the way they want us to handle
it. They want to pass us the guid and I'm to verify that on our database
(we have a duplicate database with all of their contact's information).
This is also done on a diferent server so the session variables wouldn't
work...unless we wrote the session variables to the database and
verified them from there.

I think they may have to bend a little if they want to secure the
application a little more.

Thanks for your help.

Rob

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
That verification protocol sounds like a prime candidate for a Web
Service... Until they implement that, it sounds like you have a Web
application that acceses their Website on the back end? Perhaps you could
somehow "hide" the interaction with their Website? i.e., Send the request
with the guid parameter behind the scenes, never allowing the end user to
see or modify them? There's really no way to secure an app that relies on
the integrity of the end user as the first line of security...

"Rob" <robert@.hotmail.com> wrote in message
news:exSFpHnBFHA.2032@.tk2msftngp13.phx.gbl...
> Ya Michael, you're exactly right. However I'm limited in what I can do.
> Our company is doing business with another company and they don't want
> us to access their servers and this is the way they want us to handle
> it. They want to pass us the guid and I'm to verify that on our database
> (we have a duplicate database with all of their contact's information).
> This is also done on a diferent server so the session variables wouldn't
> work...unless we wrote the session variables to the database and
> verified them from there.
> I think they may have to bend a little if they want to secure the
> application a little more.
> Thanks for your help.
> Rob
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
Thanks Michael,
I think I'll have to convince them to re-design it.

Rob

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Server Variables Question

I have a simple piece of code which is being difficult.
I have a web page (in classic asp) that will redirect to a login page if
they didn't come from that page.
Which means that they have to access my page via the login page.
The login page...which is done in asp.net and resides on a server will
be directed to a default page once logged in. On this default
page...there's a link to access my page which is on another server and
done in classic asp.
On my page I test to see if they came from the default page.
This is my code:
If request.servervariables("HTTP_REFERER") <>
"http://www.thedefaultpage.com" then
response.redirect "http://www.theloginpage.com"
end if
When I do a response.write request.servervariables("HTTP_REFERER") it
show up empty. Is there an issue with using server variables from an
aspx page to an asp page?
Thanks
Rob
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!Shouldn't that be :
If request.servervariables("HTTP_REFERER") <>
"http://www.yourserver.com/thedefaultpage.asp" then
response.redirect "http://www.yourserver.com/loginpage.aspx"
end if
?
Juan T. Llibre
ASP.NET MVP
===========
"Rob" <robert@.hotmail.com> wrote in message
news:ea4n6vABFHA.2076@.TK2MSFTNGP15.phx.gbl...
> I have a simple piece of code which is being difficult.
> I have a web page (in classic asp) that will redirect to a login page if
> they didn't come from that page.
> Which means that they have to access my page via the login page.
> The login page...which is done in asp.net and resides on a server will
> be directed to a default page once logged in. On this default
> page...there's a link to access my page which is on another server and
> done in classic asp.
> On my page I test to see if they came from the default page.
> This is my code:
> If request.servervariables("HTTP_REFERER") <>
> "http://www.thedefaultpage.com" then
> response.redirect "http://www.theloginpage.com"
> end if
> When I do a response.write request.servervariables("HTTP_REFERER") it
> show up empty. Is there an issue with using server variables from an
> aspx page to an asp page?
> Thanks
> Rob
>
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!
Ya, I tried that and I tried just the domain and neither of them worked.
I wasn't sure exactly what path would be returned so I tried to display
it on the page and it's an empty string.
Rob
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
You do realize, Rob, that if clients have bookmarked
any .aspx page in your asp.net server ( *not* on the
.asp server ) that HTTP_REFERER will be empty,
don't you ?
That would mean that the client wasn't referred from
your .asp page, yet they'd be allowed to view your
.aspx page without being re-directed.
Juan T. Llibre
ASP.NET MVP
===========
"Rob" <robert@.hotmail.com> wrote in message
news:OvV4KGBBFHA.2180@.TK2MSFTNGP12.phx.gbl...
> Ya, I tried that and I tried just the domain and neither of them worked.
> I wasn't sure exactly what path would be returned so I tried to display
> it on the page and it's an empty string.
> Rob
also a lot of proxy server strip the HTTP_REFERER header
-- bruce (sqlwork.com)
"Juan T. Llibre" <nomailreplies@.nowhere.com> wrote in message
news:OhsWjWBBFHA.612@.TK2MSFTNGP09.phx.gbl...
| You do realize, Rob, that if clients have bookmarked
| any .aspx page in your asp.net server ( *not* on the
| .asp server ) that HTTP_REFERER will be empty,
| don't you ?
|
| That would mean that the client wasn't referred from
| your .asp page, yet they'd be allowed to view your
| .aspx page without being re-directed.
|
|
|
|
| Juan T. Llibre
| ASP.NET MVP
| ===========
| "Rob" <robert@.hotmail.com> wrote in message
| news:OvV4KGBBFHA.2180@.TK2MSFTNGP12.phx.gbl...
| >
| > Ya, I tried that and I tried just the domain and neither of them worked.
| > I wasn't sure exactly what path would be returned so I tried to display
| > it on the page and it's an empty string.
| >
| > Rob
|
|
Actually it's the other way around. They login to the aspx page and when
the click on the link on the default page, they go to my asp page.
They're also passing a querystring parameter on that link and I check
for that too.
I realize the bookmark issue and I'm checking to see if the querystring
is empty or if they were referred from the default page. That ensures
that they have to access my page through the login.aspx page.
I've ommited this part because I didn't think it was relevant. I just
can't see why it would show up as empty string when trying to retrieve
the value.
I did some testing on our own server and showing the value of
request.servervariables("HTTP_REFERER") was not a problem.
Thanks
Rob
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
Is there any way of configuring the proxy server to not do that?
Rob
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
On Wed, 26 Jan 2005 18:38:09 -0800, Rob <robert@.hotmail.com> wrote:

>Actually it's the other way around. They login to the aspx page and when
>the click on the link on the default page, they go to my asp page.
>They're also passing a querystring parameter on that link and I check
>for that too.
>I realize the bookmark issue and I'm checking to see if the querystring
>is empty or if they were referred from the default page. That ensures
>that they have to access my page through the login.aspx page.
>I've ommited this part because I didn't think it was relevant. I just
>can't see why it would show up as empty string when trying to retrieve
>the value.
>I did some testing on our own server and showing the value of
>request.servervariables("HTTP_REFERER") was not a problem.
>Thanks
>Rob
>
>*** Sent via Developersdex http://www.examnotes.net ***
>Don't just participate in USENET...get rewarded for it!
Doesn't it also mean that with the correct faked referer details you
wouldn't have to log in?
I
Iain Norman | http://www.eliteforum.org
Does anyone know a better way of doing this? The client just wanted 2
things...that the user comes from the login page and that the guid that
is passed to me matches a field in another database where we keep their
contact information.
Worse case scenario is that someone fake's the referer and has to
register for an event where he would have to pay online for this guy.
ROb
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
Sounds like you need to check two things here: 1) That they are coming from
the login page, and 2) That they have successfully logged in. If either one
of these criteria is false, they need to be sent back to the login page,
right?
I would think that once the user logs in successfully, you could store the
GUID in a session variable? Just perform a check on the first page that the
HTTP_REFERRER is correct and that they are logged in -- if so, set the
Session variable to the GUID on this page. On subsequent pages just check
that the Session variable exists and is set to the valid GUID (you can
either just check that the session variable actually exists, or for more
security check it's validity against the database).
That's how I'm understanding your question anyway... I wouldn't pass
confidential info. like a GUID via QueryString.
Thanks
"Rob" <robert@.hotmail.com> wrote in message
news:OBUJOcgBFHA.2608@.TK2MSFTNGP10.phx.gbl...
> Does anyone know a better way of doing this? The client just wanted 2
> things...that the user comes from the login page and that the guid that
> is passed to me matches a field in another database where we keep their
> contact information.
> Worse case scenario is that someone fake's the referer and has to
> register for an event where he would have to pay online for this guy.
> ROb
>
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!

Thursday, March 22, 2012

server.execute vs response.redirect

Hi.
I'm just starting to shift to asp.net so forgive my question in case what i'm asking for is a obsolete function.
Using classic ASP, all of my form submission and links points to only one file which is like a index.asp, passing a hidden value indicating the type of processing it needed. From this index file, I check the hidden value passed then transfer the control to the appropriate "process" page, for this transfer of control I used "server.execute". Now using ASP wherein the form processing is embeded in the same page as the submitting form, is it still ok to use server.execute to transfer to another page after processing the page submitted? or should I use "response.redirect" instead? Or is there a better way to do this page redirection?
Thanks in advance.
Regards,
Well, in asp.net pages postback to themselves, so once you submit a form, its posting to itself.
You have different options:
1- Response.Redirect(); -- redirect you to another page
2- Server.Execute(); -- will execute a another page get the contents of it, but you will stay in the same page
3- Server.Transfer(); -- will transfer you to another page keeping the url of the first page in the address bar
Hope that helps.
regards