[CLOSED] [RAZOR] MessageBus not triggering on duplicate message

  1. #1

    [CLOSED] [RAZOR] MessageBus not triggering on duplicate message

    I have an application which consists of 2 panels. I'm using the messagebus to notify the 2nd panel of actions (button presses, etc) selected on the 1st panel

    My controller method is called the first time a new value is selected, but subsequent selection of the same option doesn't trigger the controller method

    Code in 1st panel

          items.Add(Html.X().Button()
            .ID("searchButton")
            .Text("Search")
            .DirectEvents(directEvents =>
            {
                directEvents.Click.Url = "/Shared/OnSearchButtonDirectClick";
            })
            .Listeners(listeners =>
            {
                listeners.Click.Handler = "Ext.net.Bus.publish('Search.SearchButton', 'Search');";
            }));
    Code in 2nd Panel

      Html.X().Panel()
        .ID("Panel2")
        .Title("Messages")
        .Width(300)
        .Height(300)
        .MessageBusListeners(messageBus =>
        {
            messageBus.Add(new MessageBusListener()
            {
                Name = "Search.*",
                Handler = "this.body.createChild({html: name + ' from ' + data, tag:'p'});" +
                          "$.ajax({ " +
                          "url: \"/Control2/MessageBusEvent\" + \"?data=\" + data," +
                          "success: function(data) { window.alert(data); }," +
                          "error: function(x, t, e) { window.alert(e); }," +
                          " });"
            });
        })
    Controller Code

            public JsonResult MessageBusEvent(string data)
            {
                string msg = X.Msg.Alert("DirectEvent", "MessageBusEvent " + data).ToScript();
                
                 // Do Stuff
    
                return new JsonResult() { Data = msg, JsonRequestBehavior = JsonRequestBehavior.AllowGet};
            }
    Last edited by Daniil; Jul 04, 2012 at 10:03 PM. Reason: [CLOSED]
  2. #2
    Hi,

    It looks a cache issue.

    To ensure the MessageBus listener is triggered please add the alert calling here:
    Handler = "alert('The MessageBus listener is triggered'); this.body.createChild(...)"
    Can you see this alert box on second and further clicks the button?
  3. #3
    I've added the alert box as part of the handler. It is called in all instances of the Message firing, however I'm still only getting one call to the controller method.
  4. #4
    It means we deal with the browser cache. The second and further times the response comes from the browser cache.

    The respective OutputCache attribute for the controller action or a cache buster for the URL should help.
  5. #5
    Do you have an example of setting the OutputCache attribute for the controller action or clearing the cache?
  6. #6
    just add 'cache:false' to '$.ajax' argument object
  7. #7
    perfect, thanks thats working now. Please close this issue

Similar Threads

  1. [CLOSED] Messagebus form iframe in IE8 keeps on firing
    By CarpFisher in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 26, 2012, 12:03 PM
  2. [CLOSED] [Razor] Setup Auto load panel in razor
    By UnifyEducation in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 27, 2012, 10:54 AM
  3. [CLOSED] MessageBus publish method
    By gets_gui in forum 2.x Legacy Premium Help
    Replies: 14
    Last Post: Apr 26, 2012, 8:22 PM
  4. [CLOSED] MessageBus
    By FAS in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Apr 02, 2012, 4:33 AM
  5. Replies: 4
    Last Post: Jul 17, 2010, 8:21 AM

Posting Permissions