Script callback returning ViewState?

  • Thread starter Flinky Wisty Pomm
  • Start date
F

Flinky Wisty Pomm

Okay, I'm pretty baffled by this one.

I've got a page in a popup which takes a postcode; looks up a list of
addresses for that postcode; then uses a callback to get the details
for a specific address, build a JS object and pass it back to the
window.opener.

This used to work, but without any obvious cause it has started
throwing an error. The error text comprises the XML returned from the
server AND (mysteriously) the viewstate. Here's the callback method:

<code>

public string GetCallbackResult()
{
return LoadSingleAddressAsXml(_callbackArg);
}

private string LoadSingleAddressAsXml(string addressId)
{
Connection accountDetails = GetAccountDetails();
PostcodeAnywhereProvider data = new
PostcodeAnywhereProvider(accountDetails);
FullAddress address = data.getAddress(addressId);

StringWriter Output = new StringWriter(new StringBuilder());
XmlSerializer s = new XmlSerializer( typeof( FullAddress ) );
s.Serialize(Output,address);

Trace.Warn(Output.ToString());

return outstring;
}

</code>

The trace shows a perfectly correct response without any additional
text.

The JS looks like this

<code>
addInitFunc(initCallback);

function initCallback()
{
pageUrl='/PostcodePopup.aspx';
_InitWebCallback();
}
function doCallback()
{
var list = getSingleElement("selAddress", "select");
var aId = list.options[list.selectedIndex].value;

WebForm_DoCallback('__Page',aId,receiveCallBack,null,oncallbackerror,true);
}

function onCallbackError(e)
{
alert("Oops! An error occurred while contacting the server!\nPlease
try again in a moment\n"+e);
}

function receiveCallBack(xml)
{
var oDomDoc = Sarissa.getDomDocument();
oDomDoc.loadXML(xml);
var oAddress = parseAddress(oDomDoc);
sendAddress(oAddress);
}
</code>

The onCallbackError function is called and my alert runs something like

Oops! An error occurred on the server, please try again in a moment
/wEWHQLggdzjDgLJrO+CAQLAzrGoBwLt/YqPAwLO547CDgLt/ZbPAgLO55qCDgLt/dIPAs7n1sIPAu39vs8DAs7nooIPAu39+o8BAs7nvsQEAu39xk8CzueKhAQCk6Wj9QcC7f2Cjg4Ck6WPtQcC7f3uzwECk6XL9QQC7f3qgQcCk6XXtQQC7f32wQYCk6WT9AUCzufeQwKTpf+1BQLO56oDAs7n5sMBAs7n8oMBOUBN2Lkkie4wjPMIfrnhEv/BivE=
<Address Building="My Parent's Address" Street="My Parent's Road"
Locality1="Deepest Darkest Derbyshire" Locality2=" Locality3=""
town="None Worth Mention" postcode="ABC 123" county="Derbyshire"
country-id="335" address-id="0" />
 
N

Nilesh Deshpande

Hi,

Did you check whether XML you are getting is valid? Please post XML
 
F

Flinky Wisty Pomm

It's not a problem with the XML because no validation is occurring at
any point - the script callback just returns a string, which in this
case happens to be an XML fragment, but I might switch to JScript
objects at some point. The error occurs before the document is loaded
because control passes to onCallbackError instead of receiveCallback.

The XML is fine, and matches what I get in the alert() except that the
alert also contains the ViewState

Forgive the odd schema but I've not finished setting up the
serialization.

<code>

<?xml version="1.0" encoding="utf-16"?>
<Address xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" Building="3 Dale Avenue"
Street="Dale Avenue" Locality1="Long Eaton" Locality2="" Locality3=""
town="Nottingham" postcode="NG10 1NP" county="Derbyshire"
country-id="335" address-id="0">
<CountyId>0</CountyId>
<Country>United Kingdom</Country>
<CountryCode>uk</CountryCode>
<AddressStartDate>0001-01-01T00:00:00</AddressStartDate>
<AddressEndDate>0001-01-01T00:00:00</AddressEndDate>
<IsPrimaryAddress>false</IsPrimaryAddress>
</Address>

</code>
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top