473,406 Members | 2,633 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,406 software developers and data experts.

What is my website name

I am looking for a property in the page object that would return something like
"http://localhost:1530/myapp"
What property should I look for?

--
Arne Garvander
Certified Geek
Professional Data Dude
Aug 2 '07 #1
15 2040
On Aug 2, 11:12 pm, Arne <A...@discussions.microsoft.comwrote:
I am looking for a property in the page object that would return something like
"http://localhost:1530/myapp"
What property should I look for?
Arne, you can use the Request.ServerVariables() method

http://www.4guysfromrolla.com/webtech/092298-3.shtml

Aug 2 '07 #2
"Arne" <Ar**@discussions.microsoft.comwrote in message
news:94**********************************@microsof t.com...
>I am looking for a property in the page object that would return something
like
"http://localhost:1530/myapp"
What property should I look for?
Request.ServerVariables["HTTP_HOST"]
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 2 '07 #3
page.request.url works better
--
Arne Garvander
Certified Geek
Professional Data Dude
"Mark Rae [MVP]" wrote:
"Arne" <Ar**@discussions.microsoft.comwrote in message
news:94**********************************@microsof t.com...
I am looking for a property in the page object that would return something
like
"http://localhost:1530/myapp"
What property should I look for?

Request.ServerVariables["HTTP_HOST"]
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 2 '07 #4
No they don't work so well
The page.request.uri works better.
--
Arne Garvander
Certified Geek
Professional Data Dude
"Alexey Smirnov" wrote:
On Aug 2, 11:12 pm, Arne <A...@discussions.microsoft.comwrote:
I am looking for a property in the page object that would return something like
"http://localhost:1530/myapp"
What property should I look for?

Arne, you can use the Request.ServerVariables() method

http://www.4guysfromrolla.com/webtech/092298-3.shtml

Aug 2 '07 #5
"Arne" <Ar**@discussions.microsoft.comwrote in message
news:6E**********************************@microsof t.com...
page.request.url works better
How exactly does it "work better"...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 2 '07 #6
Dim fullappname as string = Request.Url.Host
Dim port as string = Request.ServerVariables("SERVER_PORT")
Dim fullpathandport as string = "The full URL and port for the application root is : " & "http://" & fullappname & ":" &
port & Request.ApplicationPath & "/"

See a working example at : http://asp.net.do/test/apppath.aspx
( the last line returns the info you want ... )


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/
======================================
"Arne" <Ar**@discussions.microsoft.comwrote in message news:94**********************************@microsof t.com...
>I am looking for a property in the page object that would return something like
"http://localhost:1530/myapp"
What property should I look for?

--
Arne Garvander
Certified Geek
Professional Data Dude

Aug 3 '07 #7
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OY**************@TK2MSFTNGP02.phx.gbl...
Dim fullappname as string = Request.Url.Host
Dim port as string = Request.ServerVariables("SERVER_PORT")
Dim fullpathandport as string = "The full URL and port for the application
root is : " & "http://" & fullappname & ":" & port &
Request.ApplicationPath & "/"
What if it's https...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 3 '07 #8
I don't have a server certificate handy to test this, but this should cover that :

Dim fullappname as string = Request.Url.Host
Dim port as string = Request.ServerVariables("SERVER_PORT")
Dim MyUrl As Uri = Request.Url
Dim fullappnameProtocolAndPort As String = "The full URL, protocol and port for the application root is : " _
& Server.HtmlEncode(MyUrl.Scheme) & "://" & fullappname & ":" & port & Request.ApplicationPath & "/"


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/
======================================
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message news:%2****************@TK2MSFTNGP03.phx.gbl...
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:OY**************@TK2MSFTNGP02.phx.gbl...
>Dim fullappname as string = Request.Url.Host
Dim port as string = Request.ServerVariables("SERVER_PORT")
Dim fullpathandport as string = "The full URL and port for the application root is : " & "http://" & fullappname &
":" & port & Request.ApplicationPath & "/"

What if it's https...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 3 '07 #9
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OZ**************@TK2MSFTNGP03.phx.gbl...
>I don't have a server certificate handy to test this, but this should cover
that :
I normally use something like this:

string strWebRoot = (Request.ServerVariables["HTTPS"] == "off" ? "http://" :
"https://") + Request.ServerVariables["SERVER_NAME"];
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 3 '07 #10
You get portnumber, protocol
page.Request.Url.Scheme + "://" + page.Request.Url.Authority + _
"/" + page.Request.Url.Segments(1)
--
Arne Garvander
Certified Geek
Professional Data Dude
"Mark Rae [MVP]" wrote:
"Arne" <Ar**@discussions.microsoft.comwrote in message
news:6E**********************************@microsof t.com...
page.request.url works better

How exactly does it "work better"...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 3 '07 #11
Request.ServerVariables["SERVER_NAME"]; and Request.Url.Host return the same object, right ?

You're missing the application's name and the port, per the OP's request, though.

There's many ways to skin a cat.

Dim fullappname as string = Request.Url.Host
Dim port as string = Request.ServerVariables("SERVER_PORT")
Dim prot as object = IIf(Request.ServerVariables("HTTPS")="on", "https://", "http://")
Dim path as String = prot.ToString() & fullappname & ":" & port & Request.ApplicationPath

....will also do the job.

:-)


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/
======================================
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message news:e7**************@TK2MSFTNGP05.phx.gbl...
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:OZ**************@TK2MSFTNGP03.phx.gbl...
>>I don't have a server certificate handy to test this, but this should cover that :
I normally use something like this:
string strWebRoot = (Request.ServerVariables["HTTPS"] == "off" ? "http://" : "https://") +
Request.ServerVariables["SERVER_NAME"];
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 3 '07 #12
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:eW**************@TK2MSFTNGP02.phx.gbl...
Request.ServerVariables["SERVER_NAME"]; and Request.Url.Host return the
same object, right ?
Yes - AFAIK, Request.Url is just a wrapper around Request.ServerVariables...
You're missing the application's name and the port, per the OP's request,
though.
Probably... :-)
There's many ways to skin a cat.

Dim fullappname as string = Request.Url.Host
Dim port as string = Request.ServerVariables("SERVER_PORT")
Dim prot as object = IIf(Request.ServerVariables("HTTPS")="on",
"https://", "http://")
Dim path as String = prot.ToString() & fullappname & ":" & port &
Request.ApplicationPath

...will also do the job.
Indeed.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 3 '07 #13
That's very compact, Arne.

That only leaves the port to be added :

Dim port as string = Request.ServerVariables("SERVER_PORT")
Dim fullpath as string = page.Request.Url.Scheme + "://" + page.Request.Url.Authority + ":" + port + "/" +
page.Request.Url.Segments(1)

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/
======================================
"Arne" <Ar**@discussions.microsoft.comwrote in message news:2D**********************************@microsof t.com...
You get portnumber, protocol
page.Request.Url.Scheme + "://" + page.Request.Url.Authority + _
"/" + page.Request.Url.Segments(1)
--
Arne Garvander
Certified Geek
Professional Data Dude
"Mark Rae [MVP]" wrote:
>"Arne" <Ar**@discussions.microsoft.comwrote in message
news:6E**********************************@microso ft.com...
page.request.url works better

How exactly does it "work better"...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


Aug 3 '07 #14
page.request.uri

--
<a href="http://1pakistangifts.com">Send Gifts to Pakisan at #Pakistan Gifts
Store</a| <a href="http://dotspecialists.com">Leading Software offshoring
and outsourcing service provider</a| <a
href="http://websitedesignersrus.com">Professional Websites at affordable
prices</a>
"Arne" <Ar**@discussions.microsoft.comwrote in message
news:94**********************************@microsof t.com...
>I am looking for a property in the page object that would return something
like
"http://localhost:1530/myapp"
What property should I look for?

--
Arne Garvander
Certified Geek
Professional Data Dude


Aug 6 '07 #15
re:
!page.request.uri

That does *not* produce what the OP requested.

The OP wants to :

1. include the port number
2. *not* include the page's name

Please review this thread. The answer has already been provided in it.


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/
======================================
"Enigma Boy" <en*******@pp.newsgroups.userwrote in message news:CT*****************@fe103.usenetserver.com...
page.request.uri

--
<a href="http://1pakistangifts.com">Send Gifts to Pakisan at #Pakistan Gifts Store</a| <a
href="http://dotspecialists.com">Leading Software offshoring and outsourcing service provider</a| <a
href="http://websitedesignersrus.com">Professional Websites at affordable prices</a>
"Arne" <Ar**@discussions.microsoft.comwrote in message news:94**********************************@microsof t.com...
>>I am looking for a property in the page object that would return something like
"http://localhost:1530/myapp"
What property should I look for?

--
Arne Garvander
Certified Geek
Professional Data Dude



Aug 6 '07 #16

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

Similar topics

21
by: PassingBy | last post by:
I recently came across a template site selling cd's and was wondering what the groups opinion is of this? I purchased one of the cd's and the templates are great and Im looking forward to...
6
by: Doc | last post by:
I'm trying to get to the bottom of a problem I've been having with publishing a freebie website. I'm using a program called WebEasy. Using a very simple site upload as an example, in this case a...
1
by: Dean R. Henderson | last post by:
I setup FormsAuthentication on a couple websites where it has been working as expected for a long time. I used this code to setup the same type of authentication on a new website I am working on...
3
by: Wayne Gibson | last post by:
Hi, Is it possible to determine what web server is running a website, if so how? Also is it possible to determine if the web site is running locally or remotely. Thanks Wayne
2
by: yasmike | last post by:
I am having a problem with my secure website on our internal network. The secure website is hosted on our Windows 2000 Server running IIS 5.0. If you try and access the website from a browser from...
5
by: rockdale | last post by:
Hi, all: I have a website with its own login page. Now one of my clients want their employees log into my website from their website. They want to have their login page (look and feel are...
11
by: Paul Brady | last post by:
Apparently, I have been living on the wrong planet. I have written 15 databases in Microsoft Access in the past 10 years, some of which are split, one uses ODBC interface with a SQL server, one...
2
klarae99
by: klarae99 | last post by:
Hello, I am working in Access 2003 to create a database to record information about an annual fundraiser. I was hoping someone could review my table structure and make sure that it is normalized...
4
by: Mandar | last post by:
Hi, I have written some code in C# to programmatically create a website and an application pool. Both seems to be getting created alright with whatever settings I have applied. However, when I...
11
by: rajatagl | last post by:
Hi I have created my web pages in asp.net I have a registered domain name and space please tell me how to upload my website i my website database is not attached so tell me how first ready my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
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...
0
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,...
0
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...

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.