Link to home
Start Free TrialLog in
Avatar of QuinnDester
QuinnDesterFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Redirect using JavaScript and dynamic destination URL C#

I need to redirect the user from my redirect page to a dynamic url  using JavaScript. in C# Code behind

I dont know how to pass the URL to the JavaScript  in order for it to redirect.

I was using this
Response.AppendHeader("Refresh", "1; URL=" + redirecturl + "\"");
but this doesnt work in older browsers for some reason.

only other way open to me is JavaScript as the page needs to load before the redirect

This is rather Urgent so any help offered is greatfully recieved

Thank you
ASKER CERTIFIED SOLUTION
Avatar of erikTsomik
erikTsomik
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of QuinnDester

ASKER

how would i implement that in C# Code behind and pass the URL to it...
I have tried this

        HtmlGenericControl metaTag1 = new HtmlGenericControl("meta");
        metaTag1.add("HTTP-EQUIV", "Refresh");
        metaTag1.add("content", "60");
        metaTag1.add("URL", redirecturl);
        head.meta = metaTag1;

but this is giving me lots of errors

ie

System.Web.UI.HtmlControls.HtmlGenericControl' does not contain a definition for 'add' and no extension method 'add' accepting a first argument of type

and

Head' does not contain a definition for 'meta' and no extension method 'meta' accepting a first argument of type
got it using this in my code behind.
   
 MyRefresh.ID = "MyRefresh";
        MyRefresh.Attributes["content"] = "1;url=" + redirecturl;

and this in the page code
<meta id="MyRefresh" http-equiv="refresh" runat="server"/>

thanks