【问题标题】:how to run response.redirect on for loop如何在 for 循环上运行 response.redirect
【发布时间】:2013-05-28 07:35:48
【问题描述】:

我有应该运行 atau 的进程转到 url,但它应该在 for 循环上运行:

For i = 0 To ds.Tables(0).Rows.Count - 1
            idCustomer = ds.Tables(0).Rows(i)("House").ToString()
            amt = ds.Tables(0).Rows(i)("OPR_BALANCE").ToString()
            lang = "0"
            aid = "000000"
            Dim result As String = "http://soap.Services.com:2121/WS.aspx/?c=1&id=" + idCustomer + "&lang=" + lang + ""
            Response.Redirect(result)

Next

但是现在,根据我的代码,重定向到 url 并且,由于重定向,进度会自动停止。

是否可以通过在 for 循环中重定向到 URL 来运行进程?

【问题讨论】:

    标签: asp.net vb.net web-services response.redirect


    【解决方案1】:

    在循环内重定向不起作用。您需要以其他方式调用该服务。 尝试使用WebClientDownloadString 方法。通过这个提取result

    Dim client As New WebClient()
    Dim result As String = client.DownloadString("http://soap.Services.com:2121/WS.aspx/?c=1&id=" + idCustomer + "&lang=" + lang )
    

    【讨论】:

    • 谢谢,对我帮助很大:)
    【解决方案2】:

    你不能使用 response.redirect() 来做到这一点。相反,您可以使用客户端代码(JS)来执行此逻辑。在 JS 中做你的逻辑并用 JS 打开新页面。

    您可以使用 jquery 来调用 web 方法。该 webmethod 可以为您处理数据库并将数据作为 json 对象返回。然后你可以在 jquery 中执行你的逻辑来打开新页面

    希望对你有帮助

    【讨论】:

      【解决方案3】:

      一旦你调用重定向你就完成了......你不能重定向到多个页面......它不合逻辑......

      看看这个讨论:Redirect loop

      【讨论】:

        猜你喜欢
        • 2020-03-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-07-18
        • 2016-05-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多