title: Get Route Data from Request
body: <p>I'm developing a web app with asp.net mvc 2. This app, has a controller with some asynchronous operations that return json or ajax... I call it by jquery and works fine!</p>
  
  <p>My script is on the MasterPage, so this operations can be called by any View that inherits from this MasterPage.</p>
  
  <p>My question is, How could I know ... what is the controller and action that are requesting the asynchronous operation?</p>
  
  <p>I tried this:</p>
  
  <pre><code>if (this.RouteData.Values["controller"] == "Product" &amp;&amp; this.RouteData.Values["action"] == "Index") {    
  }
  </code></pre>
  
  <p>but this get the current action (my assync action... or... "THIS" action!), I want the request.</p>
  
  <p>I saw it because, if the request came from Home/Index or Home/Contact or Customer/Index or Product/Index my result of json can be diferent, so, I'd like to test what's the controller and action.</p>
  
  <p>thanks!</p>
  
  <p><strong>---- Edited</strong></p>
  
  <p>It's a system of job monitoring of my customer. I do something like this:</p>
  
  <pre><code>//every second I get info in my assync action:
  $(document).ready(function () {
    var interval = window.setInterval(GetJobs, 1000);
  });
  
  function GetJobs() {
  
          $.getJSON('&lt;%=Url.Action("Index", "AssyncJob", new { area = "Admin"}) %&gt;', function (r) {
  
              /// ----------- Info in MasterPage (All views need it) ------------ //
              // setup the time of server... 
              $("#time").html(r.time);                
              // setup the jobs are running... (
              $("#running").html("");
              if (r.jobcount == 1) 
                 $("#running").html("There is one job running!");
              else if(r.jobcount &gt; 1) 
                 $("#running").html(r.jobcount + " jobs running!");
  
  
              /// ----------- Info in Home/Index ------------ //
  
              if ($("#jobstoped")) { $("#jobstoped").html(r.jobstoped); }
  
              // get a list of jobs... (in my action this info is in Cache)
              if (r.jobs != null) {
                  $(r.jobs).each(function () {
                      if ($("#job" + this.id)) {
  
                          if (this.IsRunning) {
                              if (!$("#job" + this.id).hasClass("running")) {
                                  $("#job" + this.id).addClass("running");
                              }
                          } 
                          else if (this.IsStoped) {
                              if (!$("#job" + this.id).hasClass("stoped")) {
                                  $("#job" + this.id).addClass("stoped");
                              }
                          }
                          else if (this.IsEnding) {
                              if (!$("#job" + this.id).hasClass("finished")) {
                                  $("#job" + this.id).addClass("finished");
                              }
                          }
  
               // --- there is a lot of info and rules that I fill for each job in list
  
  
                      }
                  });
  
              }
          });
  </code></pre>
  
  <p>}</p>
  
  <p>I return some infos and works fine but I need to return the list of jobs only on Index action at Home controller, because this... I need to know what's the route are requesting the assync action ... to improve performace and avoid unnecessary information!</p>
  
  <p>Well if you can help my... I would greatly appreciate it! =D</p>
  
  <p>Thanks again!</p>