473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Read IP address from Cookie

Hello!

Have a site that contains both ASP (3.0) and ASP.NET files.
When I log inn, my login.asp write info to a cookie to use for
authentication in my asp.net files. One of the things I write to the cookie
is the users local IP address. My problem comes when I try to "use" this IP
address in my asp.net files. When I print out the IP adress from the cookie,
it looks like theis:

127%2E0%2E0%2E1

It has to be in a format like this: 127.0.0.1

How can this be done correct??
---------------------------------------------------------------
This is how I read from the cookie in my asp.net file:

Dim ip As String = Request.Cookies("login")("ip")
Response.Write(ip & "<br>")

OUTPUT: 127%2E0%2E0%2E1
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
This is how I make the cookie in my login.asp -file:
response.Cookies("login")("ip") = Request.ServerVariables("REMOTE_ADDR")
-----------------------------------------------------------------------------------------------
Thanks for all tips :)
Nov 19 '05 #1
7 1614
Try decoding using Server.DecodeHtml(Request.Cookies("login")("ip"))

Happy .NETing
Darren Kopp
http://blog.secudocs.com/

Nov 19 '05 #2
Oyvind,

You'll want to utilize:

Server.HtmlEncrypt

and

Server.HtmlDecrypt

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Øyvind Isaksen" <oy****@webressurs.no> wrote in message
news:eA**************@TK2MSFTNGP09.phx.gbl...
Hello!

Have a site that contains both ASP (3.0) and ASP.NET files.
When I log inn, my login.asp write info to a cookie to use for
authentication in my asp.net files. One of the things I write to the
cookie is the users local IP address. My problem comes when I try to "use"
this IP address in my asp.net files. When I print out the IP adress from
the cookie, it looks like theis:

127%2E0%2E0%2E1

It has to be in a format like this: 127.0.0.1

How can this be done correct??
---------------------------------------------------------------
This is how I read from the cookie in my asp.net file:

Dim ip As String = Request.Cookies("login")("ip")
Response.Write(ip & "<br>")

OUTPUT: 127%2E0%2E0%2E1
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
This is how I make the cookie in my login.asp -file:
response.Cookies("login")("ip") = Request.ServerVariables("REMOTE_ADDR")
-----------------------------------------------------------------------------------------------
Thanks for all tips :)

Nov 19 '05 #3
It's URLEncoded (or is that HTMLEncoded?)
Look for the corresponding Decode method, or just do a .Replace()

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Øyvind Isaksen" wrote:
Hello!

Have a site that contains both ASP (3.0) and ASP.NET files.
When I log inn, my login.asp write info to a cookie to use for
authentication in my asp.net files. One of the things I write to the cookie
is the users local IP address. My problem comes when I try to "use" this IP
address in my asp.net files. When I print out the IP adress from the cookie,
it looks like theis:

127%2E0%2E0%2E1

It has to be in a format like this: 127.0.0.1

How can this be done correct??
---------------------------------------------------------------
This is how I read from the cookie in my asp.net file:

Dim ip As String = Request.Cookies("login")("ip")
Response.Write(ip & "<br>")

OUTPUT: 127%2E0%2E0%2E1
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
This is how I make the cookie in my login.asp -file:
response.Cookies("login")("ip") = Request.ServerVariables("REMOTE_ADDR")
-----------------------------------------------------------------------------------------------
Thanks for all tips :)

Nov 19 '05 #4
That should be :

Server.URLEncode
and
Server.URLDecode

See the sample at : http://asp.net.do/test/URLDecode.aspx


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in message
news:eT*************@TK2MSFTNGP10.phx.gbl...
Oyvind,

You'll want to utilize:

Server.HtmlEncrypt

and

Server.HtmlDecrypt

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Øyvind Isaksen" <oy****@webressurs.no> wrote in message
news:eA**************@TK2MSFTNGP09.phx.gbl...
Hello!

Have a site that contains both ASP (3.0) and ASP.NET files.
When I log inn, my login.asp write info to a cookie to use for authentication in my
asp.net files. One of the things I write to the cookie is the users local IP address.
My problem comes when I try to "use" this IP address in my asp.net files. When I print
out the IP adress from the cookie, it looks like theis:

127%2E0%2E0%2E1

It has to be in a format like this: 127.0.0.1

How can this be done correct??
---------------------------------------------------------------
This is how I read from the cookie in my asp.net file:

Dim ip As String = Request.Cookies("login")("ip")
Response.Write(ip & "<br>")

OUTPUT: 127%2E0%2E0%2E1
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
This is how I make the cookie in my login.asp -file:
response.Cookies("login")("ip") = Request.ServerVariables("REMOTE_ADDR")
-----------------------------------------------------------------------------------------------
Thanks for all tips :)


Nov 19 '05 #5
It's URL encoded.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Curt_C [MVP]" <software_at_darkfalz.com> wrote in message
news:47**********************************@microsof t.com...
It's URLEncoded (or is that HTMLEncoded?)
Look for the corresponding Decode method, or just do a .Replace()

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Øyvind Isaksen" wrote:
Hello!

Have a site that contains both ASP (3.0) and ASP.NET files.
When I log inn, my login.asp write info to a cookie to use for
authentication in my asp.net files. One of the things I write to the cookie
is the users local IP address. My problem comes when I try to "use" this IP
address in my asp.net files. When I print out the IP adress from the cookie,
it looks like theis:

127%2E0%2E0%2E1

It has to be in a format like this: 127.0.0.1

How can this be done correct??
---------------------------------------------------------------
This is how I read from the cookie in my asp.net file:

Dim ip As String = Request.Cookies("login")("ip")
Response.Write(ip & "<br>")

OUTPUT: 127%2E0%2E0%2E1
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
This is how I make the cookie in my login.asp -file:
response.Cookies("login")("ip") = Request.ServerVariables("REMOTE_ADDR")
-----------------------------------------------------------------------------------------------
Thanks for all tips :)

Nov 19 '05 #6
Yea, my bad. URL encoded.

-Darren

"Darren Kopp" <da********@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Try decoding using Server.DecodeHtml(Request.Cookies("login")("ip"))

Happy .NETing
Darren Kopp
http://blog.secudocs.com/

Nov 19 '05 #7
Oops,

Thanks for the correction Juan. I've pulled that out of memory, knew it was
one of the two, and remembered it wrong...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
That should be :

Server.URLEncode
and
Server.URLDecode

See the sample at : http://asp.net.do/test/URLDecode.aspx


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:eT*************@TK2MSFTNGP10.phx.gbl...
Oyvind,

You'll want to utilize:

Server.HtmlEncrypt

and

Server.HtmlDecrypt

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Øyvind Isaksen" <oy****@webressurs.no> wrote in message
news:eA**************@TK2MSFTNGP09.phx.gbl...
Hello!

Have a site that contains both ASP (3.0) and ASP.NET files.
When I log inn, my login.asp write info to a cookie to use for
authentication in my asp.net files. One of the things I write to the
cookie is the users local IP address. My problem comes when I try to
"use" this IP address in my asp.net files. When I print out the IP
adress from the cookie, it looks like theis:

127%2E0%2E0%2E1

It has to be in a format like this: 127.0.0.1

How can this be done correct??
---------------------------------------------------------------
This is how I read from the cookie in my asp.net file:

Dim ip As String = Request.Cookies("login")("ip")
Response.Write(ip & "<br>")

OUTPUT: 127%2E0%2E0%2E1
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
This is how I make the cookie in my login.asp -file:
response.Cookies("login")("ip") = Request.ServerVariables("REMOTE_ADDR")
-----------------------------------------------------------------------------------------------
Thanks for all tips :)



Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Larry R. Baker | last post by:
Is it possible to grab a client side IP Address using JavaScript in an htm page? I have a web page hosted on a non-ASP server and I want a piece of code in JavaScript to grab the IP address of the...
1
by: | last post by:
How does one read and write the cookie expiration date. At the moment my code is returning a value BUT a garbled value: '//Write cookie... Response.Cookies("Propsect").Expires = Date() + 1 ...
5
by: Nicolae Fieraru | last post by:
Hi All, I use VC .Net 2003 and I want to create a small program which is able to read the source code of a web site. I have a textbox with the URL, a button and a multiline textbox for the...
1
by: Mike | last post by:
Hello, I can't find any javascript that reads and writes cookies with keys, so that it is compatible with ASP (I want to read and write cookies from both javascript and ASP) for example in...
12
by: Jason Shohet | last post by:
I've asked this on the asp ng, but couldn't get any advice, wondering if anyone here can help... GOAL: place a .NET cookie, in a user's cookie folder, containing the machinename of the current...
4
by: Marcos | last post by:
Hi, This may or may not be a simple question, but I have been able to find an answer to this issue in all my searches. In an ASP application, I'm creating a cookie that stores a username from...
1
by: Todd Brewer | last post by:
I have an ASP.NET 2.0 site that stores a cookie on the browser. Instead of the domain name (www.somename.com) it comes accross as the IP address of the server. This works in Firefox, but fails...
1
by: Doogie | last post by:
Hi, I am having a problem reading a cookie that I can see is being created. I create the cookie in my global.aspx.vb page like so: Sub Session_Start(ByVal sender As Object, ByVal e As...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.