I am building a WCF Application for Push notification where user have to first subscribe himself and after subscribe the client get response from WCF.
i use wsDualHttpBinding as binding and callback in WCF.
I don't want to call recursive function from client. I use timer in WCF and WCF throw messages when any update is happen in database. My WCF is ready but unable to display messages on client side.
Now my question is how to Display messages when client get response from WCF.
My client side code on aspx.cs is:
public void SendResult(string message)//I got message = "Test String"
{
Response.Write(message);// it throw error "Response is not available in this context."
// I also use this code
HttpContext.Current.Response.Write(message); // but it also give error "Object reference not set to an instance of an object."
}
This is a very critical question and i have to just display the message
Any help will be appreciate.
Edit 1
Service Method call
protected void Page_Load(object sender, EventArgs e)
{
SocialProfilesService.SocialClient client =
new SocialProfilesService.SocialClient(new InstanceContext(this));
client.Subscribe(userid)
}
Edit 2
I also tried
SynchronizationContext uiSyncContext;
uiSyncContext = SynchronizationContext.Current;
public void SendResult(string message)//I got message = "Test String"
{
SendOrPostCallback callback = delegate(object state)
{
Response.Write(message);
};
uiSyncContext.Post(callback, message);
}
but it also gives me the error "Object reference not set to an instance of an object." Wht to do