How to determine the base URL of current page

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;
}
 
J

Juan T. Llibre

Maybe we could all agree that posts which explain a solution to a problem,
whether requested or not, have "FAQ Solution:" in the subject ?

;-)
 
M

Mark Rae

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... :)
 
J

Juan T. Llibre

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.

:-(
 
M

Mark Rae

!> 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...
 
R

rote

But if i remember i think Juan had a website of something related.
Can't reacll the website URL.
Can you forward it.
Patrick
 
J

Juan T. Llibre

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top