.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

dSHIFT Blog - WCF Callback Events and Callback Behavior

Posted By: dSHIFT Team     Posted Date: November 08, 2012    Points: 2   Category :SharePoint
WCF Callback Events and Callback Behavior - Supporting a Callback (events) based design is expected to be a part of any modern client/server based implementation. WCF framework has ample support for Callbacks and usually it is all about setting the right properties/attributes in your implementation….. There is a lot of information available online ….. how to use Duplex Channel to support Callback mechanism….. However, one important piece of the puzzle is the CallbackBehavior and not a lot of samples around talk about it……WCF application running on top of SharePoint 2010. Setting up the DuplexChannel for Callbacks to work was relatively easy… Following is a small compilation of my findings http://www.dshift.com/blog/wcf-callback-events-and-callback-behavior/

What are your thoughts on this blog? Share your views

View Complete Post

More Related Resource Links

Basic Instincts: Implementing Callback Notifications Using Delegates


Delegates are a critical aspect of the Microsoft® . NET Framework and are required learning for many programmers. They will take some time to master, but once you learn how to program with delegates, you'll be thrilled with the possibilities they offer.

Ted Pattison

MSDN Magazine December 2002

How to CATCH "Invalid postback or callback argument" exception?



How can I catch this exception? I do not want it to stop my page execution. Can/Should I do that?

Server Error in '/' Application.
Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally

How to send parameters to the AJAX callback function


I need to send som parameters to the callback function of my AJAX call, how can i do that:



function DoSomething(id, textbox1)
  AjaxHandler.FindSomethingInDB(id, Callback);

function Callback(result, eventArgs)
  // Here i need to know the value of textbox1 from the function "DoSomething"


Callback has separate session


Hi, I am using uploadify to upload files to the server. After the user selects one image, a callback is issued and the image is stored to the server. To track which images are saved, I stored each item in a generic list and later store that list inside a session variable.

The problem is, the callback has a different session then the page where I will be posting back to parse the session variable.

My question is why do callbacks have different sessions then the underlying page that issued the callback.


XAML - ValueConverter Parameters and PropertyChanged callback

Hi I am trying to use a IValueConverter on the flowdocument of a richtextbox. However, ideally I'd like to be able to inject some dependencies into the converter on construction or perhaps with a setter of some sort. Previously I've been using an IoC to construct a formatter-type object and can obviously specify the constructor dependency quite easily. However, I was hoping to use XAML and the IValueConverter as much as possible, but specifying the converter in the Grid.Resources requires a parameterless constructor. Are there other ways in which I can do this or do I need to think about the problem differently. In addition, because you cannot bind to a RichTextBox, I have introduced an AttachedProperty. Here's some code     Public Shared ReadOnly DocumentProperty As DependencyProperty = DependencyProperty.RegisterAttached("Document", GetType(FlowDocument), GetType(RichTextBoxExtensions), RichTextBoxFrameworkPropertyMetaData) Private Shared Function RichTextBoxFrameworkPropertyMetaData() As FrameworkPropertyMetadata Dim metaData = New FrameworkPropertyMetadata metaData.BindsTwoWayByDefault = True metaData.AffectsRender = True metaData.PropertyChangedCallback = New PropertyChangedCallback(Sub(obj, e) If _recursionProtection.Contains(Thread.CurrentThread) Then Return Dim rtb = CType

WCF - First call to Callback instance from Server takes considerable time to make it to the client.

Hello. There's a performance problem we are facing that we are unable to fix using DuplexChannels. The first call made by the client to the server reaches the server instantly. The first call made by the server to the first client using a Callback proxy will take several seconds to reach the client. All subsequent calls to the client (as well as other clients) will reach and execute instantly. The client connects to the Server using a proxy to IServiceProvision, supplies an instance to an implementation of IClientCallback and calls IServiceProvision.Start(). The server instantly processes the call and makes an asynchronous call to IClientCallback.DoWork(), which takes several seconds to enter the client's DoWork() implementation. The remainder of the execution then runs smoothly. Also, the server will experience such a slowdown only for the very first call of the first client that connects to it. Is it normal for the Callback interface to take so much time to warmup, only on the first call to the first client? Below is the full source code. Thanks for any information you may provide. Cheers Mike Shared Class Library using System.ServiceModel; namespace Test { [ServiceContract(Namespace = "http://test/IService", CallbackContract = typeof(IClientCallback))] public interface IServiceProvision { [OperationContract] void Start(); [OperationContract] void

redirect to site by Callback (Google checkout)

Hi i am getting all callbacks from google checkout...now what i need to do is :when i click on button to place order, if suceed then redirects me to thank you pagei dont want to go on thank you page, on clicking on button i should be redirected to mysite..i am getting each status in callback page, so what can i do when order is placed, to redirect to mysiteThanks in advance

WSDualHttpBinding Callback in cocurrent mode

Hi, Would it be possible to make the callback in cocurrent mode when the server calls the clients through callback interface? We are using WSDualHttpBinding between Server and Client. At this moment, when the server sends a message throught the callback interface to the client while client is busying with processing some data, client will keep processing data until finish then responds to the call from the server. We would like as soon as the server calls using the callback, the client need to respond immediately. Is it possible?   The reason we need this is we want to add the ability to issue a Cancel command for the long progressing work on client from the server. The client is is checking a flag regularly to determine whether to continue work during the processing. The callback from the server to client will need to set the flag as soon as the message is send out. Thanks  

Adding a Callback to the Window Title Property

Hi all-   I have a quick question.  I have a customized window, based on the Window object.  Is there a way to create a Callback handler on the Title Property, so that I can basically capture and perform my own customized actions when the Title property is changed?  I have no problems adding custom dependency properties (as below), but adding a callback to an existing property from the base class is where I am a little lost and need guidance.   Thanks for any help. Chris   public class WindowBase : Window { // Several Dependency Properties exist as below, with callbacks which trigger on the change of the property // The trick is to find a way to add a callback to the Title property of Window public string Caption { get { return (string)GetValue(CaptionProperty); } set { SetValue(CaptionProperty, value); } } public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register("Caption", typeof(string), typeof(WindowBase), new PropertyMetadata(OnCaptionChanged));

Single class with service and callback contract

Can a single class implement service and callback contract. Thanks-= JL =-

Infinite timeout for callback operation

I am using a callback contract to pull messages from an external service. Apparently messages could received could be received at irregular intervals. I am having an issue where my service is timing out, I believe this is because if there is no callback for a while (I guess 10 minutes by default). Is there a way to set idle timeout to infinite? Is it recommended to set it to infinite or is there a better approach.-= JL =-

Two different services, same callback contract

I have two different service using the same callback contract.  Is that permitted?  I am getting weird behavoior.  When a client subscribes to the two callbacks, the messages seem to come back to the wrong callback.Batman

Provide object over network on callback method

Hello. I am building a client server video monitoring system. I will have a user (viewer) connect to a web page on a server, pick a camera and see what is going on at the particular location. A general WCF question: How can I access VideoSource custom class object remotely on the server via WCF? Basically, I have a VideoSource and VideoSourcePlayer that work great, when are within one process, but how can I access VideoSource object remotely? An example link would be enough. Thank you.  Max Pavlov http://maxpavlov.com

use callback on htmltablerow


I have a html table row which I want to act so that if i  click on it it updates just a specific datalist on the page which is wrapped in a updatepanel and do not update the rest of my page.


my tr tag is :



        <tr  id='item'  title ='<%#Eval("orgnr") %>'  runat="server" class='<%# IIf( Container.ItemIndex Mod 2 = 0 , "row" , "altrow" )%>' onclick ="setAdd(this.title)" >
<td><%#DataBinder.Eval(Container.DataItem, "orgnr")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "name")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "email")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "website")%></td>
<td class="money"><%#DataBinder.Eval(Container.DataItem, "logo")%></td>


setAdd is the function in code behind that does datalist binding for me and I need to pass title of item into that function.


   Protected Sub setAdd(ByVal orgnr As String)
        orginfoDL_orgInfoTab.DataSource = objReed.getAddsByOrg(CType(orgnr, In

Dropdownlist posted back html content,firefox alarms "Invalid postback or callback argument"


Ok probably you might have seem a dozens of post's titled "Invalid postback or callback argument" but this one is different.

Application that i am creating is simple content editor using the FCK editor.net Control (the content is HTML Encoded before saving t0 DB and then Decoded back again when displaying). just a simple drawing of of its ui is like this

DdlPages < listing the pages Whose regions/controls value can be edited> Databound

DdlRegions <listing the controls whose content can be edited> Databound on DdlPages selected index change

===========Retreived from DropDownlistRegions selected Index Change===========

txtName <a simple name for the region, user friedly identity >

==> FCK Editor <==

<Save Button> <Discard Button>


I am not such a good designer but hope you understand the UI layout.

This thing works flawless on IE 6,7,8


DropdownlistRegions holds the content to be displayed in the txtName and FckEditor. This is done by forming a custom concatenated column containing the txtName and Fckeditor(HTML content) separated by a ' ^ ' character. and then databound the column to the Dropdownlist value property.

So on selected index chang

howto call callback function in c#



I need to call some c++ properity dll in my c# code and not sure how to implement a callback function call in c#

I saw the vb 6.0 code it was implemented like this

        NC_registerOnServiceAvailable m_link, AddressOf DllInterface.OnServiceAvailable

' typedef void ( __stdcall *tOnServiceAvailable )( const tTOResultEnum );
Public Sub OnServiceAvailable(ByVal result As Long)
End Sub

and not sure how to do equivalent in C#

I appreciate your suggestions,



extra request to a default page on a callback


Hello guys,

I have a following issue on production server (the development environment is free of it) And it's only happening in Internet Explorer.

I add callback to a page in the old-fashioned way -> Page.ClientScript.RegisterClientScriptBlock(...)

The scenario is:

1) The default page is being loaded. On Page_OnLoad it assigns a NULL to some session key. Let's call it Control -> Session["Control"] = null;

2) User presses a button and gets redirected to a next page (let's call it NextPage.aspx) using javascript event -> window.location.assign(....) (also tried .href = ... - no help)

3) The NextPage.aspx assigns some value to Session["Control"] on Page_OnLoad

5) User clicks a button on the NextPage.aspx and a callback request is being sent to a server....

TA DA!!! The interesting part:

6) Along with the request to the NextPage.aspx another request is being sent to the default page.

7) The only response is being recieved by a client is a response from the NextPage.aspx BUT since the code on the default page is being executed it puts null to the Session["Control"] which screws all my following scenario. the default page doesn't recognize the request as a callback? so if(IsCallback) {} doesn't he

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend