【问题标题】:Searching on 404 page returns back to 404 page back在 404 页面上搜索返回到 404 页面返回
【发布时间】:2013-08-28 21:53:54
【问题描述】:

我们有一个 404 页面。当我们在 404 页面时,我们有搜索框。如果我们尝试从搜索框中搜索,它会再次返回到 404 页面。我们该如何处理?

PS:我的搜索按钮在用户控件内,而用户控件在母版页内。

当我们访问以下网站时; http://www.x.com/dk

转到 404。

然后,如果我们从 th,s 404 页面进行搜索,它会将我们定向到下面的链接; http://www.x.com/dk?404%3bhttp%3a%2f%2fwww.x.com%3a80%2fdk

我的网络配置集

   <customErrors mode="Off" defaultRedirect="Error.aspx">
      <error statusCode="404" redirect="PageNotFound.aspx" />
   </customErrors>
    <httpErrors>
    <remove statusCode="404" subStatusCode="-1" />
    <error statusCode="404" path="/PageNotFound.aspx" prefixLanguageFilePath=""            responseMode="ExecuteURL" />
    </httpErrors>

【问题讨论】:

    标签: asp.net iis iis-7 web-config http-status-code-404


    【解决方案1】:

    我通过 javascript 解决了这个问题

    <script type="text/javascript">
    
        $("#btnSearch").attr("onclick", "Search('/Search.aspx?text=' + encodeURI($('#txtSearchInput').val())); return false;");
    
        function Search(text) {
            location.href = text;
        }
    
    </script>
    

    【讨论】:

      猜你喜欢
      • 2020-05-12
      • 1970-01-01
      • 2020-10-28
      • 1970-01-01
      • 2019-09-10
      • 2011-11-22
      • 1970-01-01
      • 1970-01-01
      • 2021-10-27
      相关资源
      最近更新 更多