How to determine the base URL of current page

  • Thread starter Thread starter Anonieko
  • Start date Start date
A

Anonieko

private string GetSiteUrl()
{
string baseUrl = null;
HttpContext c = HttpContext.Current;
if (c != null)
{
string port = c.Request.ServerVariables["SERVER_PORT"];
if (port == null || port.Equals("80") ||
port.Equals("443"))
port = String.Empty;
else
port = ":" + port;

string protocol =
c.Request.ServerVariables["SERVER_PORT_SECURE"];

if (protocol == null || protocol.Equals("0"))
protocol = "http://";
else
protocol = "https://";

baseUrl = protocol +
c.Request.ServerVariables["SERVER_NAME"] + port +
c.Request.ApplicationPath;
}
return baseUrl;
}
 
Maybe we could all agree that posts which explain a solution to a problem,
whether requested or not, have "FAQ Solution:" in the subject ?

;-)

How many solutions to problems have you accumulated over the years...?

I've got hundreds of 'em... :-)
 
re:
!> How many solutions to problems have you accumulated over the years...?
!> I've got hundreds of 'em... :-)

Thousands...but I don't post them unprompted.

;-)

I proposed to a major publisher doing a book with them.
They said no...and 8 months later published a book with the same idea.

:-(





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/
======================================
 
!> How many solutions to problems have you accumulated over the years...?
!> I've got hundreds of 'em... :-)

Thousands...but I don't post them unprompted.
Exactly.

I proposed to a major publisher doing a book with them.
They said no...and 8 months later published a book with the same idea.

Maybe an "ASP.NET Tips & Tricks" website would be better, although there are
a fair few of those already...
 
But if i remember i think Juan had a website of something related.
Can't reacll the website URL.
Can you forward it.
Patrick
 
re:
!> But if i remember i think Juan had a website of something related.

I worked on http://www.aspnetfaq.com/ for a few months,
when the transition from ASP.NET Beta 2 to the release version was gpoing on.

The site owners were a bit impatient and wanted a major makeover,
but I was a lone developer...and a lot of details were changing very quickly.

The aspnetfaq site is, still, exactly as I left it a few months ago.

I *do* have a FAQ site at my server, but it's not a Q&A site.

It's a guidance site for ASP.NET beginners which, besides offering basic pointers
to where info about ASP.NET can be found, also offers tips on how to manage
interactions in this, and other, ASP.NET newsgroup(s).

That site is : http://asp.net.do/faq/ ...and is in my standard sig.

I'm still mulling over whether a Q & A FAQ site would be a good project.



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/
======================================
 
Back
Top