Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 我有没有办法在IIS或web.config中安排302重定向?_Asp.net_Iis 7.5 - Fatal编程技术网

Asp.net 我有没有办法在IIS或web.config中安排302重定向?

Asp.net 我有没有办法在IIS或web.config中安排302重定向?,asp.net,iis-7.5,Asp.net,Iis 7.5,我有一些网站,需要设置为302重定向在午夜的具体日期。我知道我可以通过IIS或web.config为站点设置重定向,但这两种方式都需要我在午夜手动进行更改。我是否可以提前设置重定向,以便在将来某个日期开始重定向?您可以在global.asax文件中进行重定向 protected void Application_Start(Object sender, EventArgs e) { DateTime dateToRedirect = new DateTime(2015, 4, 1);

我有一些网站,需要设置为302重定向在午夜的具体日期。我知道我可以通过IIS或web.config为站点设置重定向,但这两种方式都需要我在午夜手动进行更改。我是否可以提前设置重定向,以便在将来某个日期开始重定向?

您可以在global.asax文件中进行重定向

protected void Application_Start(Object sender, EventArgs e) {
    DateTime dateToRedirect = new DateTime(2015, 4, 1);
    HttpContext context = HttpContext.Current;

    if(DateTime.Now > dateToRedirect)
    {
        if(...) // Conditional code for setting which pages get redirected
        {
            string newUrl = "http://www.example.com";
            context.Response.Redirect(newUrl);
        }
    }
}