【问题标题】:AjaxMethods in Windows Azure not workingWindows Azure 中的 AjaxMethods 不起作用
【发布时间】:2011-05-03 08:16:50
【问题描述】:

我们正在使用 VS2010 中的 ReportViewer (rdlc) 控件在 Azure Web 应用程序中显示报告,该控件运行良好。最近,我的客户要求我捕获 ReportViewer 的打印事件并在服务器上记录一个条目。我已经用打印按钮钩住了。当我在本地环境中运行 Web 应用程序时,这非常有效。但是,在 Azure 上,永远不会从客户端调用 Ajax 方法。请建议怎么做? Azure 环境中的 Ajax 有限制吗?

我正在后面的代码中在 Page_Load 上注册页面

protected void Page_Load(object sender, EventArgs e)
{
  Ajax.Utility.RegisterTypeForAjax(typeof(Pages.Report));

  ImageButton btnPrint = new ImageButton();
  btnPrint = ((ImageButton)(this.FindControl("ctl00$" + ReportViewer1.ClientID.Replace("_","$") + "$ctl06$ctl06$ctl00$ctl00$ctl00")));
  btnPrint.Attributes["onclick"] += "attachEventForPrint();";
}

 [AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]

 public static void LogEvent(int pLoggingEvent)
 {
  // Addded logic to log event
 }

在 ASPX 文件中,JS 中添加了以下函数

 function attachEventForPrint() {
   if (typeof (Report) != "undefined") {
                Report.LogEvent(4);
            }
        }

【问题讨论】:

  • 我从未使用过 Microsoft Ajax,但我使用 jQuery 并且 Ajax 在我们的 MVC 应用程序中没有问题。

标签: c# asp.net asp.net-ajax azure report-viewer2010


【解决方案1】:

好消息是,我认为使用 ajax 控件没有任何限制 - 我已经使用了一些,它们都可以正常工作。

一些需要检查的事情可能是:

  • 您能否使用 Fiddler 查看 HTTP 跟踪 - 单击打印按钮时是否正在向服务器发送请求?
  • 您能否使用 javascript 调试器检查出现 attachEventForPrint 时是否没有报告错误?
  • “状态”是否存在任何问题 - 尤其是会话存储?

要检查的另一件事是是否有更易于维护的方式来访问打印按钮 - "$ctl06$ctl06$ctl00$ctl00$ctl00" 看起来像是现在或将来某个时候自找麻烦

【讨论】:

  • 好回复斯图尔特!我按照您的建议使用了 Fiddler,发现单击 Azure 中的“打印”按钮时没有生成任何请求。对于会话存储,我使用的是 TableSessionState 提供程序。它有任何特定配置吗?
  • 如果 Fiddler 中没有显示任何内容,则表明客户端代码出错 - 检查 javascript 方面 - 例如使用 IE F12、chrome 调试器或 firebug。祝你好运!
猜你喜欢
  • 2012-07-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-03
  • 2018-05-07
  • 2014-02-11
  • 1970-01-01
相关资源
最近更新 更多