Hi all,
I have a situation where a Web Server at an install site does not currently
have a publically registered Domain Name associated with the site. This
requires that the a user access the site from a remote (outside the LAN)
browser using the IP address, as in http://192.35.78.234 .
Currently in my code I use the following syntax to obtain the Root Web path
which I then append as a prefix to Images and Links in external documents
(Excel files) so the recipient of an HTML Email or one of the spreadsheets
can both resolve the images or click on a spreadsheet link to view a page on
the site.
Dim strRootWeb As String = Me.Request.Head ers.Item("Host" ).ToString
strRootWeb = "http://" + strRootWeb
Session.Add("Ro otWeb", strRootWeb)
Then for a working link in an external document I will do something like:
Public strRootWeb = Session("RootWe b")
strRootWeb & "/Common/PageView.aspx
But this does not work if the name of the Web Server is not publically
registered with DNS servers.
Thanks for any help on resolving the IP address of a Web Server root. 14 4035
"John Kotuby" <jk*******@comc ast.netwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Not sure if this is what you want or not but, based on the subject of your
post, you can get the IP address of the host web server into a Session
variable like this:
Session["HostIP"] = Request.ServerV ariables["LOCAL_ADDR "].ToString();
--
Mark Rae
ASP.NET MVP http://www.markrae.net
Thanks for the reply Mark,
I think that will give me the actual IP address of the Server box that the
Web Application is running on. That would work for me if the was directly
connected to the Internet.
However, in this situation, the Web Server is behind a firewall and being
accessed via NAT.
What I am really looking for is the Public IP Address that is used in the
request to get to the Router that then finds the Server behind the firewall.
I am thinking that it is contained somewhere in the HttpRequest object just
as the Me.Request.Head ers.Item("Host" ).ToString returns the string for the
Root Web as requested by the client.
When the browser sends out a request for http://www.url.com that is
immediately converted by a public DNS server to an IP address. It is that
public IP address that I seek to grab, not matter what Web server is hosting
our application. I have been looking for the property that contains the IP
address but can't seem to find it in the documentation.
Thanks...
"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:ec******** ******@TK2MSFTN GP06.phx.gbl...
"John Kotuby" <jk*******@comc ast.netwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Not sure if this is what you want or not but, based on the subject of your
post, you can get the IP address of the host web server into a Session
variable like this:
Session["HostIP"] = Request.ServerV ariables["LOCAL_ADDR "].ToString();
--
Mark Rae
ASP.NET MVP http://www.markrae.net
if the firewall (or load balancer) is doing nat translation (which it should
be), then its not available (as only the firewall knows it).
your best bet is to add to the ipaddress to the web.config as a setting
-- bruce (sqlwork.com)
"John Kotuby" wrote:
Thanks for the reply Mark,
I think that will give me the actual IP address of the Server box that the
Web Application is running on. That would work for me if the was directly
connected to the Internet.
However, in this situation, the Web Server is behind a firewall and being
accessed via NAT.
What I am really looking for is the Public IP Address that is used in the
request to get to the Router that then finds the Server behind the firewall.
I am thinking that it is contained somewhere in the HttpRequest object just
as the Me.Request.Head ers.Item("Host" ).ToString returns the string for the
Root Web as requested by the client.
When the browser sends out a request for http://www.url.com that is
immediately converted by a public DNS server to an IP address. It is that
public IP address that I seek to grab, not matter what Web server is hosting
our application. I have been looking for the property that contains the IP
address but can't seem to find it in the documentation.
Thanks...
"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:ec******** ******@TK2MSFTN GP06.phx.gbl...
"John Kotuby" <jk*******@comc ast.netwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Not sure if this is what you want or not but, based on the subject of your
post, you can get the IP address of the host web server into a Session
variable like this:
Session["HostIP"] = Request.ServerV ariables["LOCAL_ADDR "].ToString();
--
Mark Rae
ASP.NET MVP http://www.markrae.net
"John Kotuby" <jk*******@comc ast.netwrote in message
news:eV******** ******@TK2MSFTN GP03.phx.gbl...
What I am really looking for is the Public IP Address that is used in the
request to get to the Router that then finds the Server behind the
firewall.
Hmm - if the box was connected to the Internet, it would be simple enough to
fetch its IP address as seen by the outside world by inspecting the
HttpResponse returned from something like: http://www.whatismyip.org/
However, as Bruce has explained, because of the NAT and firewall in the
equation it's going to be pretty much impossible to determine this in this
case...
--
Mark Rae
ASP.NET MVP http://www.markrae.net
Thanks guys, I was hoping to find the requested public IP address in the
Request object somewhere, but apparently it is not to be found.
However gathering the response from http://www.whatismyip.org/ might just
work after all.
I am running a workstation that is behind a Gateway Firewall device and it
uses NAT. When I click on the whatismyip link above I get the public IP
Address that I must use to connect to my workstation from home via RDP
(using a non-standard Port of course).
So if I am getting the Public IP of a NATed workstation, why wouldn't that
technique work for a NATed Web Server...it's just another box? In fact any
response from another public site can ONLY return the public IP address of a
NATed box. Brilliant!
I am going brain-dead today because I can't even recall how to get the
HttpResponse returned from something like: http://www.whatismyip.org/ in my
code-behind or maybe in the Global.asax itself.
I will resort to hard-coding the IP Address in web.config or global.asax if
necessary, as that is not too difficult, but I see possibly 30 or more
deployments that might need this sort of thing.
Thanks again...you guys are always helpful.
"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:uq******** ******@TK2MSFTN GP03.phx.gbl...
"John Kotuby" <jk*******@comc ast.netwrote in message
news:eV******** ******@TK2MSFTN GP03.phx.gbl...
>What I am really looking for is the Public IP Address that is used in the request to get to the Router that then finds the Server behind the firewall.
Hmm - if the box was connected to the Internet, it would be simple enough
to fetch its IP address as seen by the outside world by inspecting the
HttpResponse returned from something like: http://www.whatismyip.org/
However, as Bruce has explained, because of the NAT and firewall in the
equation it's going to be pretty much impossible to determine this in this
case...
--
Mark Rae
ASP.NET MVP http://www.markrae.net
"John Kotuby" <jk*******@comc ast.netwrote in message
news:OL******** *******@TK2MSFT NGP05.phx.gbl.. .
I am going brain-dead today because I can't even recall how to get the
HttpResponse returned from something like: http://www.whatismyip.org/ in
my code-behind or maybe in the Global.asax itself.
string strHostIP = String.Empty;
using (WebClient objWebClient = new WebClient())
{
using (StreamReader objStreamReader = new
StreamReader(ob jWebClient.Open Read("http://www.whatismyip. org/")))
{
strHostIP = objStreamReader .ReadToEnd();
objStreamReader .Close();
}
}
--
Mark Rae
ASP.NET MVP http://www.markrae.net
Well, I think I'm getting closer, but maybe just chasing my tail.
I converted your code example to VB and here is what is ending up in my
Session variable.
Error: blank User-Agent header is not allowed! Please ask the author of your
IP address checking client to specify their client's name in the User-Agent
header
Maybe it's something I failed to do when creating the WebClient?
From the same machine that I am using as the Web Server, still I get just
the correct IP address in my Web Browser and that is ALL that is being sent
back.
Why should the web browser be any different than the WebClient?
Oh well...It's 5 oclock on a Friday. I knew it had to be 5 oclock somehwere!
"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:em******** ******@TK2MSFTN GP02.phx.gbl...
"John Kotuby" <jk*******@comc ast.netwrote in message
news:OL******** *******@TK2MSFT NGP05.phx.gbl.. .
>I am going brain-dead today because I can't even recall how to get the HttpResponse returned from something like: http://www.whatismyip.org/ in my code-behind or maybe in the Global.asax itself.
string strHostIP = String.Empty;
using (WebClient objWebClient = new WebClient())
{
using (StreamReader objStreamReader = new
StreamReader(ob jWebClient.Open Read("http://www.whatismyip. org/")))
{
strHostIP = objStreamReader .ReadToEnd();
objStreamReader .Close();
}
}
--
Mark Rae
ASP.NET MVP http://www.markrae.net
"John Kotuby" <jk*******@comc ast.netwrote in message
news:el******** ******@TK2MSFTN GP02.phx.gbl...
[top-posting corrected as usual]
I converted your code example to VB
Why on earth did you do that...?
Error: blank User-Agent header is not allowed! Please ask the author of
your IP address checking client to specify their client's name in the
User-Agent header
Use this URL instead: http://www.netikus.net/show_ip.html
--
Mark Rae
ASP.NET MVP http://www.markrae.net
Try the following:
Private Sub MyIPaddressButt on_Click(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyIPaddressButt on.Click
Dim strHostIP As String = String.Empty
Using objWebClient As New WebClient()
Using objStreamReader As StreamReader = New
StreamReader(ob jWebClient.Open Read
("http://www.whatismyip. com/automation/n09230945.asp") )
strHostIP = objStreamReader .ReadToEnd()
objStreamReader .Close()
End Using
End Using
End Sub
Jamal
"John Kotuby" <jk*******@comc ast.netwrote in message
news:el******** ******@TK2MSFTN GP02.phx.gbl...
Well, I think I'm getting closer, but maybe just chasing my tail.
I converted your code example to VB and here is what is ending up in my
Session variable.
Error: blank User-Agent header is not allowed! Please ask the author of
your IP address checking client to specify their client's name in the
User-Agent header
Maybe it's something I failed to do when creating the WebClient?
From the same machine that I am using as the Web Server, still I get just
the correct IP address in my Web Browser and that is ALL that is being
sent back.
Why should the web browser be any different than the WebClient?
Oh well...It's 5 oclock on a Friday. I knew it had to be 5 oclock
somehwere!
"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:em******** ******@TK2MSFTN GP02.phx.gbl...
>"John Kotuby" <jk*******@comc ast.netwrote in message news:OL******* ********@TK2MSF TNGP05.phx.gbl. ..
>>I am going brain-dead today because I can't even recall how to get the HttpRespons e returned from something like: http://www.whatismyip.org/ in my code-behind or maybe in the Global.asax itself.
string strHostIP = String.Empty; using (WebClient objWebClient = new WebClient()) { using (StreamReader objStreamReader = new StreamReader(o bjWebClient.Ope nRead("http://www.whatismyip. org/"))) { strHostIP = objStreamReader .ReadToEnd(); objStreamReader .Close(); } }
-- Mark Rae ASP.NET MVP http://www.markrae.net This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: doltharz |
last post by:
Please Help me
i'm doing something i though was to be REALLY EASY but it drives me
crazy
The complete code is at the end of the email
(i mean newsgroup article),
i always use Option Explicit
and Response.Expires=-1,
|
by: Scott |
last post by:
I'm trying to set a session variable after displaying a form, then capture
the Session variable on postback. For some reason, the below code always
returns the form, not the "Step 2" results part.
What am I doing wrong? It's on a local network server, not on the web if
that matters.
<%
'* Step 2: Display results...
|
by: Al Jones |
last post by:
This is a repost form the vbscript newgroup - if this isn't the appropriate
group would you point me toward one that is.
Basically, I seem to be losing session data part way though preparing an
email from (possibly) three seperate forms.
the following code is the end of a routine which stashes data from the first
form
off to session...
|
by: Stephen |
last post by:
I have a .NET (1.1 framework) application that is losing a
session variable on only a few PC's. The main page is
loading up in a frame in a Portal application. On the
Page_Load it stores an object with the user id and
password into the session.
The web page includes a set of links. When the user
clicks on a link, another page within...
|
by: MrBiggles |
last post by:
Here's the sitch:
I read in a csv file with 60000 lines (20 fields per record), and store
the data to a local array. The file is read in and stored just fine and
pretty quick.
Now, if I try to assign that array to a session variable it chokes.
e.g. create array and load each element with a row from the file (btw,
each row is an array as...
| |
by: Sarah Marriott |
last post by:
Our website contains session variables that are used to validate if a user is
logged in etc. We have found that these variables are randomly lost while
navigating the website.
We set up some basic code (as shown below) which used a meta tag to refresh
an aspx page every second. It tests whether there is any content in a
session variable,...
|
by: laredotornado |
last post by:
Hi,
When a user logs into our site, we create a session variable to denote
the session is active and another to denote who is logged in. Once
the user closes the browser and re-opens it, the session is destroyed
and the variables are gone.
How can I keep the session alive for 24 hours even if the user closes
and re-opens the browser?
|
by: YYZ |
last post by:
I'm using asp, not asp.net. I've got some open ended questions that I
was really hoping someone in here could answer, or direct me to some
resources that will help me answer them on my own.
First, the session object. When a new user comes to my site, asp
creates a session object, and a session id on that object. That
session id is sent...
|
by: Twayne |
last post by:
Hi,
If ever a newbie wants to know how much he has to learn yet, he only has
to look here<g>!! ANYway:
PHP 5.2.5; XP Pro SP2+, local Apache Server
My actual question is: How do I get a POST variable into a session
variable so I can use it in any other page I want to use it in?
Apparently posted variables are only available in the...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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...
|
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...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |