0

我有这个 WebMethod 可以重定向到该服务器上的另一个页面。

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
public static Boolean realizaConsulta(Dictionary<string, string> datos)
{
    System.Web.HttpContext.Current.Response.Redirect("PRepConsulta.aspx", false);
}

但我得到这个错误:

Microsoft JScript 运行时错误:Sys.Net.WebServiceFailedException:服务器方法“realizaConsulta”失败并出现以下错误:System.InvalidOperationException-- 身份验证失败。

是什么导致了这个错误?


看看我尝试过的其他选项:

        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
        public static Boolean realizaConsulta(Dictionary<string, string> datos)
        {
           System.Web.HttpContext.Current.Server.Execute("PRepConsulta.aspx", false);
        }

它可以工作,因为它会转到 PRepConsulta.aspx 并执行 UNDERCODE,但该页面从不显示。

我也试过:

        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
        public static Boolean realizaConsulta(Dictionary<string, string> datos)
        {
               HttpContext.Current.Server.Transfer("PRepConsulta.aspx", false);
        }

但我得到了这个错误:

Microsoft JScript 运行时错误:Sys.Net.WebServiceFailedException:服务器方法“realizaConsulta”失败并出现以下错误:System.Threading.ThreadAbortException-- Subproceso anulado。

我不知道还能尝试什么

谢谢你的帮助

4

2 回答 2

1

我不确定“身份验证失败”部分,但 WebMethod 内部的 Response.Redirect 可能会破坏调用该方法的 SOAP 客户端。它期待一个布尔值,而不是重定向。

于 2010-06-28T14:55:50.840 回答
0

好的,我要组织应用程序的流程:

来自我的客户,在 javascript 中,我正在调用 Web 服务

PageMethods.realizaConsulta(Datos);

在我的代码隐藏中,我必须执行 pageMethod 并调用另一个页面

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
public static Boolean realizaConsulta(Dictionary<string, string> datos)
{

    clsGeneral consulta;
    DataTable dtTemp = new DataTable();

    using (consulta = new clsGeneral("SQLConn"))
    {
        consulta.consultaPrograma(ref dtTemp, datos["Codigo"],  Int16.Parse(datos["Cod_Actividad"]), Int16.Parse(datos["Cod_SubActividad"]), datos["FechaIni"], datos["FechaFin"]);
        HttpContext.Current.Session["Consulta"] = dtTemp;

    //THIS ARE THE 3 DIFFERENT WAYS I HAVE TRIED TO CALL THE PRepConsulta.aspx,
    //I DONT KNOW IF THERE IS A BETTHER WAY TO DO IT

    //System.Web.HttpContext.Current.Response.Redirect("PRepConsulta.aspx", false);
    //HttpContext.Current.Server.Transfer("PRepConsulta.aspx", false);
    //System.Web.HttpContext.Current.Server.Execute("PRepConsulta.aspx",writer, false);
    }
    return true;
}

谢谢

于 2010-06-28T16:43:33.043 回答