1

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

ankit Gupta
  • 313
  • 1
  • 5
  • 19

1 Answers1

0

You should look at this article. This should help. It gives a nice simple example of subscribing and pushing updates.

Article

As per our discussion. It seems your service is working fine. I am assuming that you are calling SendResult appropriately and passing in the message. Here is another thing you can try... This is java script alert from Asp.net

    Page.RegisterStartupScript("startScript", "<script language=JavaScript>Message("+message+" );</script>");

    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "testmsg", "<script>alert('your message goes here');</script>");
Tabish Sarwar
  • 1,505
  • 1
  • 11
  • 18