I'd use a generic handler (ASHX):
<%@ WebHandler Language="C#" Class="Handler" >
using System;
using System.Web;
public class Handler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.RedirectLocation = "<a href="http://new.location.net/optional/path" target="_blank">http://new.location.net/optional/path</a>";
context.Response.StatusCode = 301; // 301 = Moved Permanently | 302 = Object moved | 307 = Temporary redirect
}
public bool IsReusable => false;
}
No need to load session state or go through the whole page life cycle.
Or use Application_BeginRequest on global.asax:
protected void Application_BeginRequest(object sender, EventArgs e)
{
var context= ((System.Web.HttpApplication) sender).Context;
if (/* whatever condition */)
{
context.Response.RedirectLocation = "<a href="http://new.location.net/optional/path" target="_blank">http://new.location.net/optional/path</a>";
context.Response.StatusCode = 301; // 301 = Moved Permanently | 302 = Object moved | 307 = Temporary redirect
context.Response.End();
}
}