Using Server.Transfer to show a page that informs the user that the web site is at maintenance mode.
At global.asax:

void Application_BeginRequest(object sender, EventArgs e)
{
    if (Request.IsLocal)
        return;

    if (ConfigurationManager.AppSettings["MaintenanceMode"] == "true")
    {
        if (Request.AcceptTypes != null && Request.AcceptTypes[0] == "text/html")
            Server.Transfer("~/UserMessage.aspx?Maintenance");
    }
}  

Works well except when looking at the page source code I see that the CSS path has been updated but images' paths are not.
Any suggestions?

有帮助吗?

解决方案

I would use app_offline.htm in the application root or at the very least Response.Redirect if I were you, Server.Transfer does not change the HTTP address, so you have to be careful redirecting all assets to the underlying page or make all addresses absolute

其他提示

The server.transfer is actually stop the execution of a page and start execute a different page, the page that you give it.

The result is that the user see a different page under the same url.

This have nothing to do with image path. Also the images are not pass from asp.net except if you have set even images to pass from asp.net processing. Also on the code that you have give us you do not make any transfer if they are images, but you check for the text/html.

Now if you have move the execution to a different css, the image path is not change, only the page that the user see change.

Maybe you mean that you use the MapPath() and this is not change according to the new directory ?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top