Client (/Script) Callback fails on certain IE6 installlation

B

Brian

Hi,
I've been trying to get a simple client / script callback to work. I
was using IE6 to the ASP Development Server / IIS 5 and it just
didn't work. I ended up using an example straight from an asp 2.0 book
and it still didn't work. However I noticed that it worked on firefox on
the development machine, and also IE6 and firefox from a remote machine.

I set various breakpoints and noticed that the firefox callback ends up
in the correct looking callback in the aspx file on the server, but
the failing IE6 browser ends up in SECOND call to Page_Load. It's as
if that specific browser <-> server configuration fails to properly
let IIS know its a special call, not just a standard http request.

I stepped through the failing IE6 code and it goes into a file called
WebResource.axd?blahblah and into an expanded
function WebForm_DoCallback(eventTarget, eventArgument,
eventCallback, context, errorCallback, useAsync)
which create a new ActiveXObject("Microsoft.XMLHTTP")
and calls it. But as I say it ends up in page_load on the server
and the callback fails.

So my question is, why would a simple example fail on a single IE6
installation in such a bizarre manner, and why would firefox locally
and IE6 + firefox remotely all work fine? I checked the settings in
the local IE and it seems ok.
It's generally a well behaved browser, so, I'm actually now scared to
use this functionality as I don't want support issues with a % of
similar browsers once anything is released.

Any ideas? Its a worrying issue, supportwise!

Example follows for reference (from Prof Asp.Net 2.0 by Wrox)

// RandomNumber.Aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="RandomNumber.aspx.cs" Inherits="RandomNumber" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Callback Page</title>

<script type="text/javascript">
function GetNumber(){
UseCallback();
}

function GetRandomNumberFromServer(TextBox1, context){
document.forms[0].TextBox1.value = TextBox1;
}
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="Get Random Number"
onclick="GetNumber()" />
<br />
<br />
<asp:TextBox ID="TextBox1" Runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>

--------------------------------
// RandomNumber.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class RandomNumber : System.Web.UI.Page,
System.Web.UI.ICallbackEventHandler
{
private string _callbackResult = null;

protected void Page_Load(object sender, EventArgs e)
{
string cbReference =
Page.ClientScript.GetCallbackEventReference(this,
"arg", "GetRandomNumberFromServer", "context");
string cbScript = "function UseCallback(arg, context)" +
"{" + cbReference + ";" + "}";

Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
"UseCallback", cbScript, true);
}

public void RaiseCallbackEvent(string eventArg)
{
Random rnd = new Random();
_callbackResult = rnd.Next().ToString();
}

public string GetCallbackResult()
{
return _callbackResult;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top