title: Get the name of view who called controller in ASP.NET MVC
body: <p>Is there any way to get the name of View that called method in controller and save it for example in some custom variable inside that controller's method?</p>
  
  <p>For example:</p>
  
  <p>I have one View that uses Ajax to get to InfinateScroll method in controller:</p>
  
  <pre><code>&lt;div class="container-post"&gt;
      &lt;div id="postListDiv"&gt;
          @{Html.RenderAction("PostList", "Posts", new { Model = Model });}
      &lt;/div&gt;
      &lt;div id="loadingDiv" style="text-align: center; display: none; margin-bottom: 20px;"&gt;
          &lt;img alt="Loading" src="@Url.Content("~/images/ajax-loader.gif")" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
      &lt;script src="@Url.Content("~/Scripts/jquery-1.10.2.min.js")"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          var BlockNumber = 2;
          var NoMoreData = false;
          var inProgress = false;
  
          $(window).scroll(function () {
              if ($(window).scrollTop() == $(document).height() - $(window).height() &amp;&amp; !NoMoreData &amp;&amp; !inProgress) {
                  inProgress = true;
                  $("#loadingDiv").show();
  
                  $.post("@Url.Action("InfinateScroll", "Posts")", { "BlockNumber": BlockNumber },
                      function (data) {
                          BlockNumber = BlockNumber + 1;
                          NoMoreData = data.NoMoreData;
                          $("#postListDiv").append(data.HTMLString);
                          $("#loadingDiv").hide();
                          inProgress = false;
                      });
              }
          });
      &lt;/script&gt;
  </code></pre>
  
  <p>I use this View on two pages. In one case I'm using it to show only posts from specific user (user who is logged in), and on the other view I'm showing posts from all users in database(similar to Facebook wall where you can see only your post, and NewsFeed where you can not only your's but also posts from your frineds).</p>
  
  <p>For some reason I would like to know which page was active when call for InfinateScroll method was made.</p>
  
  <p>This is the method where I would like to make some differences between those two pages so I can do some check out's later.</p>
  
  <pre><code>[HttpPost]
  public ActionResult InfinateScroll(int BlockNumber)
  {
       int BlockSize = 5;
       var posts = PostManager.GetPosts(BlockNumber, BlockSize);
       JsonModel jsonModel = new JsonModel();
       jsonModel.NoMoreData = posts.Count &lt; BlockSize;
       jsonModel.HTMLString = RenderPartialViewToString("PostList", posts);
  
       return Json(jsonModel);
  }
  </code></pre>
  
  <p>This method gets posts using helper method GetPosts and it's used for showing more posts on scroll.</p>