Response.Redirect的例外情况?

时间:2012-06-27 15:12:13

标签: c# asp.net exception post

  

可能重复:
  Call ASP.NET Function From Javascript?
  Response.Redirect causes System.Threading.ThreadAbortException

我一直收到错误:

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>

为什么我会收到此错误,您如何解决?

1 个答案:

答案 0 :(得分:0)

尝试使用:

Response.Redirect(url, false);
相关问题