473,839 Members | 1,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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")("i p")
Response.Write( ip & "<br>")

OUTPUT: 127%2E0%2E0%2E1
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
This is how I make the cookie in my login.asp -file:
response.Cookie s("login")("ip" ) = Request.ServerV ariables("REMOT E_ADDR")
-----------------------------------------------------------------------------------------------
Thanks for all tips :)
Nov 19 '05 #1
7 1627
Try decoding using Server.DecodeHt ml(Request.Cook ies("login")("i p"))

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

Nov 19 '05 #2
Oyvind,

You'll want to utilize:

Server.HtmlEncr ypt

and

Server.HtmlDecr ypt

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Øyvind Isaksen" <oy****@webress urs.no> wrote in message
news:eA******** ******@TK2MSFTN GP09.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")("i p")
Response.Write( ip & "<br>")

OUTPUT: 127%2E0%2E0%2E1
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
This is how I make the cookie in my login.asp -file:
response.Cookie s("login")("ip" ) = Request.ServerV ariables("REMOT E_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")("i p")
Response.Write( ip & "<br>")

OUTPUT: 127%2E0%2E0%2E1
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
This is how I make the cookie in my login.asp -file:
response.Cookie s("login")("ip" ) = Request.ServerV ariables("REMOT E_ADDR")
-----------------------------------------------------------------------------------------------
Thanks for all tips :)

Nov 19 '05 #4
That should be :

Server.URLEncod e
and
Server.URLDecod e

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******** *****@TK2MSFTNG P10.phx.gbl...
Oyvind,

You'll want to utilize:

Server.HtmlEncr ypt

and

Server.HtmlDecr ypt

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Øyvind Isaksen" <oy****@webress urs.no> wrote in message
news:eA******** ******@TK2MSFTN GP09.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")("i p")
Response.Write( ip & "<br>")

OUTPUT: 127%2E0%2E0%2E1
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
This is how I make the cookie in my login.asp -file:
response.Cookie s("login")("ip" ) = Request.ServerV ariables("REMOT E_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_da rkfalz.com> wrote in message
news:47******** *************** ***********@mic rosoft.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")("i p")
Response.Write( ip & "<br>")

OUTPUT: 127%2E0%2E0%2E1
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
This is how I make the cookie in my login.asp -file:
response.Cookie s("login")("ip" ) = Request.ServerV ariables("REMOT E_ADDR")
-----------------------------------------------------------------------------------------------
Thanks for all tips :)

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

-Darren

"Darren Kopp" <da********@gma il.com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
Try decoding using Server.DecodeHt ml(Request.Cook ies("login")("i p"))

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******** ********@TK2MSF TNGP12.phx.gbl. ..
That should be :

Server.URLEncod e
and
Server.URLDecod e

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******** *****@TK2MSFTNG P10.phx.gbl...
Oyvind,

You'll want to utilize:

Server.HtmlEncr ypt

and

Server.HtmlDecr ypt

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Øyvind Isaksen" <oy****@webress urs.no> wrote in message
news:eA******** ******@TK2MSFTN GP09.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")("i p")
Response.Write( ip & "<br>")

OUTPUT: 127%2E0%2E0%2E1
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
This is how I make the cookie in my login.asp -file:
response.Cookie s("login")("ip" ) = Request.ServerV ariables("REMOT E_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
13323
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 client and send it to a web page on another server. The other page will be ASP. I need this for both Netscape and IE browsers. Any ideas?
1
11119
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 '//Read cookie... ExpDate = Request.cookies("Propsect") Response.write "Prospect expiry date: " & expDate & "<br>"
5
1998
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 source code. If the web page is secure, how can I post my login details? Any help appreciated. Regards,
1
2228
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 ASP: <% Response.Cookies("user")("firstname")="John" Response.Cookies("user")("lastname")="Smith"
12
4621
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 machine the user is on. Then various .NET apps will be able to compare a value in our db, and see if the user is allowed to work on that machine. So far, in the computers' startup routine (when the computer is logged into), each computer...
4
5717
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 pageA.asp I then try to read the cookie from pageB.asp, which is inside a frame of pageC.asp.
1
4838
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 with IE 6 because of security. I went through and forced the Domain like this: this.Response.Cookies.Value = "en-MX"; this.Response.Cookies.Expires = DateTime.Now.AddDays(30); this.Response.Cookies.Domain = "somename.com"; This results in...
1
1180
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 EventArgs) Dim user As String = Current.User.Identity.Name Dim roleCookieName As String = user & "-Roles" Dim rolesList As String = Response.Cookies(roleCookieName ).Value 'Only try to create the cookie if it is not already created.
0
9855
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10649
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9426
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7829
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7018
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5682
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4487
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3136
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.