title: In MVC, how do you determine the calling action?
body: <p>I have the following controller that, along with returning images, prevents direct linking:</p>
  
  <pre><code>public class ImageController : Controller
  {
      [HttpGet]
      public ActionResult Details(string id, string file)
      {
          if (null == Request.UrlReferrer ||
              Request.UrlReferrer.Authority != Request.Url.Authority ||
              Request.UrlReferrer.AbsolutePath.ToLower() != Url.Action("Photos", "Home", new { id = id }).ToLower())
          {
              return base.File(Server.MapPath("/Content/images/notfound.jpg"));
          }
  
          // else process and return image
      }
  }
  </code></pre>
  
  <p>This works, but it has a slight smell. Is there something MVC-ier that will tell me this? I was initially hopeful about <code>ControllerContext</code>, but that wasn't it.</p>
  
  <p>Here is how I am calling this action from my view:</p>
  
  <pre><code>@foreach (var item in Model.Items)
  {
      &lt;li&gt;
          &lt;img src='@Url.Action("Details", "Image", new { id = Model.Project, file = item.ThumbnailPath })' /&gt;
      &lt;/li&gt;
  }
  </code></pre>