---
title: "GetCurrentURL"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/40065-getcurrenturl"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "Pace"
published: "2002-03-21T18:16:06.000Z"
updated: "2003-01-03T13:23:39.000Z"
replies: 3
views: 1599
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/40065-getcurrenturl"
---

# GetCurrentURL

## #1 — Pace, 2002-03-21T18:16Z

**GetCurrentURL** \- Hämtar den aktuella sidans URL med querystrings.

**Användning:**
Response.Write "Denna sidans URL: " & GetCurrentURL()

**Kod:**

```
Function GetCurrentURL()
	Dim strQueryString
	Dim strServerName
	Dim strScriptName
	Dim strURL

	strQueryString = Request.QueryString
	strServerName = Request.ServerVariables("SERVER_NAME")
	strScriptName = Request.ServerVariables("SCRIPT_NAME")

	strURL = "http://" & strServerName & strScriptName
	If strQueryString <> "" Then
		strURL = strURL & "?" & strQueryString
	End If

	GetCurrentURL = strURL
End Function
```

Permalänk: https://www.webforum.nu/p/40065

## #2 — crisse6, 2002-12-31T02:14Z

Du behover inte gora sa mycket jobb....

sida = "http://" + Request.ServerVariables("SERVER_NAME") + Request.ServerVariables("URL") + "?" + Request.ServerVariables("QUERY_STRING")

Permalänk: https://www.webforum.nu/p/899636

## #3 — Jörgen HP, 2003-01-01T00:09Z

> **crisse6 skrev:**
>
> Du behover inte gora sa mycket jobb....
> 
> sida = "http://" + Request.ServerVariables("SERVER_NAME") + Request.ServerVariables("URL") + "?" + Request.ServerVariables("QUERY_STRING")

Smartare att bygga upp sådant med funktioner än att "hårdkoda" det varje gång. :)

Permalänk: https://www.webforum.nu/p/900227

## #4 — Pace, 2003-01-03T13:23Z

Dessutom är det snyggare utan ?-tecken på slutet där det saknas en querystring:

http://www.domän.com/fil.asp
än
http://www.domän.com/fil.asp?

Permalänk: https://www.webforum.nu/p/901625

---

Tråden på webben: https://www.webforum.nu/amne/asp/40065-getcurrenturl
