You need to specify an absolute URL for the REFRESH header. Take a look at this post showing how to obtain an absolute URL from relative (you could use the ResolveServerUrl
shown there):
Response.AddHeader("REFRESH", "2;url=" + ResolveServerUrl("~/pages/home.aspx"));
For reference:
/// <summary>
/// This method returns a fully qualified absolute server Url which includes
/// the protocol, server, port in addition to the server relative Url.
///
/// Works like Control.ResolveUrl including support for ~ syntax
/// but returns an absolute URL.
/// </summary>
/// <param name="ServerUrl">Any Url, either App relative or fully qualified</param>
/// <param name="forceHttps">if true forces the url to use https</param>
/// <returns></returns>
public static string ResolveServerUrl(string serverUrl, bool forceHttps)
{
// *** Is it already an absolute Url?
if (serverUrl.IndexOf("://") > -1)
return serverUrl;
// *** Start by fixing up the Url an Application relative Url
string newUrl = ResolveUrl(serverUrl);
Uri originalUri = HttpContext.Current.Request.Url;
newUrl = (forceHttps ? "https" : originalUri.Scheme) +
"://" + originalUri.Authority + newUrl;
return newUrl;
}
/// <summary>
/// This method returns a fully qualified absolute server Url which includes
/// the protocol, server, port in addition to the server relative Url.
///
/// It work like Page.ResolveUrl, but adds these to the beginning.
/// This method is useful for generating Urls for AJAX methods
/// </summary>
/// <param name="ServerUrl">Any Url, either App relative or fully qualified</param>
/// <returns></returns>
public static string ResolveServerUrl(string serverUrl)
{
return ResolveServerUrl(serverUrl, false);
}