错误 400 错误请求

编程入门 行业动态 更新时间:2024-10-13 22:20:03
本文介绍了错误 400 错误请求 - 单独重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

SEO 公司要求将每个 404 错误请求重定向到特定 url.我要求将错误 400(错误请求)重定向到特殊页面.

我可以在 web.config 文件中完成,但要求是每个 url 到特殊页面例如stackoverflow/questions/askstackoverflow/questions/ask =>(301) stackoverflow/questions/askstackoverflow/questionsstackoverflow/questions => (301)stackoverflow/questions

有可能吗?我的应用程序是 IIS 服务器上的 ASP.NET(不是 MVC)

谢谢

解决方案

在 asp webforms 上设置一个页面,即 Redirect.aspx 来重定向所有类型为 400 的错误:

<system.web><customErrors defaultRedirect="Error.htm"mode="RemoteOnly"><错误状态代码="400"重定向=重定向.aspx"/></customErrors></system.web>

然后在页面上看到它来自的网址:

Request.UrlReferrer

然后相应地处理

The Seo Company ask for making redirect each 404 bad request to specific url. I asked for redirect an error 400 (Bad request) to special page.

I can do it in the web.config file, but the requirement is each url to special page for example stackoverflow/questions/askstackoverflow/questions/ask =>(301) stackoverflow/questions/ask stackoverflow/questionsstackoverflow/questions => (301) stackoverflow/questions

Is it possible? My application is ASP.NET (Not MVC) on IIS SERVER

Thanks

解决方案

On asp webforms set a page i.e. Redirect.aspx to redirect all the Error of type 400:

<configuration> <system.web> <customErrors defaultRedirect="Error.htm" mode="RemoteOnly"> <error statusCode="400" redirect="Redirect.aspx"/> </customErrors> </system.web>

then on the page see the Url it cames from by:

Request.UrlReferrer

then handle accordingly

更多推荐

错误 400 错误请求

本文发布于:2023-07-14 19:59:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1106688.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!