Alon M
Alon M

Reputation: 1683

Change Url of a website in webfroms while the website is running

Well, its abit hard to expline what i mean.

but, lets say you are connecting to a website called "www.active.com/active".

and you want while you are in the page, or when load the page. that the url will change.

lets say, you are just wrote "www.active.com/active" you can connecting and the url will be "www.active.com/active2" when the page is done loading.

or, while you are in the page, after 15 sec it will change to /active2.

any way?

EDIT:

without changing the page. only the url.

Upvotes: 0

Views: 929

Answers (4)

Curtis
Curtis

Reputation: 103368

This is not possible (and I'm quite glad of it!)

You are talking about editing the user's browser bar URL text box. This is a part of the user's software, and not content within the page.

Furthermore, if this was possible, hackers could convince you that you were on a site such as HSBC or Facebook, when really youre on a malicious site which is storing your details.

For answers on how to redirect to another page, see my below response:


You could do a HTML redirect after 15 seconds:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
   <title>Your Page Title</title>
   <meta http-equiv="REFRESH" content="15;url=http://www.active.com/active2">
</head>
<body>
</body>
</html>

Or if you wish for an immediate redirect, you could handle this server side:

protected void Page_Load(){
   Response.Redirect("/active2");
}

Upvotes: 2

Răzvan Flavius Panda
Răzvan Flavius Panda

Reputation: 22116

Use Response.Redirect() in Page_Load of codebehind of www.active.com/active.aspx to redirect immediately:

protected void Page_Load(object sender, EventArgs e)
{
    Response.Redirect("~/active2");
}

For timed redirection use in same aspx page:

<script type="text/JavaScript">
    setTimeout("location.href = 'www.active.com/active2.aspx';",15000);
</script>

Upvotes: 0

Frazell Thomas
Frazell Thomas

Reputation: 6111

You can use a redirect.

That could be done using a client side redirect (if you want it to occur after being on the page for some time) or using a server side redirect (if you want it to occur when the user first loads the page).

Client Side Example:

<meta http-equiv="refresh" content="5; url=http://example.com/">

Says: Load http://example.com after 5 seconds.

See: Wikipedia

Server Side Example:

Response.Redirect("/active2")

Says: Redirect user to this page using HTTP Headers

See: Developer.com

Server Side Example 2:

Server.Transfer("/active2")

Says: Redirect the request to this new page on the server (it transfers the user without ever telling the browser).

See: Developer.com

That should give you enough to cover the basics.

Upvotes: 0

Jakob Jingleheimer
Jakob Jingleheimer

Reputation: 31580

For the first one, it sounds like a URL rewrite or a forward. If you're doing a rewrite, apache has loads of different options (I see you're using asp.net, so you're probably using IIS, which I'm not sure about, but I want to say it doesn't support it). If you're doing a forward, it would be in the head.

The second one, is probably a POST function from the form.

Upvotes: 0

Related Questions