Google 404 and .NET Custom Error Pages

佐手、 提交于 2019-12-04 03:03:44
mattlant

There is a new redirect mode in ASP.NET 3.5 SP1 that you can now use so it doesn't redirect. It shows the error page, but keeps the URL the same:

"Also nice for URL redirects. If you set the redirectMode on in web.config to "responseRewrite" you can avoid a redirect to a custom error page and leave the URL in the browser untouched."

Mauro

I've handled the 404 by doing this in the global.asax file

protected void Application_BeginRequest(object sender, EventArgs e)
{
    string url = Request.RawUrl;
    if ((url.Contains(".aspx")) && (!System.IO.File.Exists(Server.MapPath(url))))
    {
        Server.Transfer("/Error/FileNotFound.aspx");
    }
}

Now, if anyone can help me with the google widget that would be great!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!