Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/310.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.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
C# 响应异常。重定向?_C#_Asp.net_Exception_Post - Fatal编程技术网

C# 响应异常。重定向?

C# 响应异常。重定向?,c#,asp.net,exception,post,C#,Asp.net,Exception,Post,可能重复: 我一直收到一个错误: mscorlib.dll中出现“System.Threading.ThreadAbortException”类型的第一次意外异常mscorlib.dll中出现“System.Threading.ThreadAbortException”类型的异常,但未在用户代码中处理线程“”(0x27ee4)已退出,代码为0(0x0) 我被告知与此有关: protected void Button1_Click(object sender, EventArgs e)

可能重复:

我一直收到一个错误:

mscorlib.dll中出现“System.Threading.ThreadAbortException”类型的第一次意外异常mscorlib.dll中出现“System.Threading.ThreadAbortException”类型的异常,但未在用户代码中处理线程“”(0x27ee4)已退出,代码为0(0x0)

我被告知与此有关:

protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("Results.aspx?Keywords=" + searchString.Text);  
    }
我想包含我的完整代码可能会有所帮助。上面的代码是我第一个asp页面上唯一的C代码

该代码与本页上的此代码相关。这也是我第二页上唯一的C代码。我只是尝试将关键字从搜索表单传递到这段代码:

if (Request.QueryString["Keywords"] != null){
        string keywords = Request.QueryString["Keywords"];
            string myAppID = "HIDDEN";
            var xml = XDocument.Load("http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&SECURITY-APPNAME=" + myAppID + "&RESPONSE-DATA-FORMAT=XML&REST-PAYLOAD&keywords=" + keywords + "&paginationInput.entriesPerPage=5");
            XNamespace ns = "http://www.ebay.com/marketplace/search/v1/services";
            var titles = from item in xml.Root.Descendants(ns + "title")
                              select new{
                                  title = xml.Descendants(ns + "title").Select (x => x.Value),
                              };
        foreach (var item in titles){
                Label1.Text += item;
            } 
        }
这段代码调用关键字值,并在api中使用它来执行搜索。xml(api)格式的代码如下:

<findItemsByKeywordsResponse xmlns="http://www.ebay.com/marketplace/search/v1/services">
<searchReslut count="5">
<item>
    <title></title>
</item>
<item>
    <title></title>
</item>
<item>
    <title></title>
</item>

为什么会出现此错误?您如何修复它?

尝试使用:

Response.Redirect(url, false);

你总是犯这个错误吗?您是否在代码中的任何位置调用
Thread.Abort()
?对于重定向和绝对重复来说完全正常。您添加了标签
asp classic
,但您所说的是
asp.net
。您是否有任何与此相关的经典.asp(不是.aspx或.cshtml)页面?@allencoded,除了例外,您第二个页面中的代码使您的站点容易受到
URL注入攻击。
asp.net。现在我再也不调用Thread.Abort()了。您看到的是,我99%的代码忽略了加载的页面,该页面不起作用。错误消失了,因为我没有得到系统线程的东西。但是我的输出看起来像这样{title=System.Linq.Enumerable+whereSelectEnumerableInterator`2[System.Xml.Linq.XElement,System.String]}