title: make controller actions' "return partialview()" automatically link to a "_partialview.cshtml" in asp.net mvc3
body: <p>I'm writing a page in MVC3, and there are a few places where I want to request a page in ajax and from the url bar too.</p>
  
  <p>If the request is a full pagerequest I want the Action to render "Example.cshtml" which is a full view.
  But is the request is an ajax request I would only want to render the "_Example.cshtml" which is a partial view.</p>
  
  <p>My code is </p>
  
  <pre><code>    if (Request.IsAjaxRequest())
      {
          return PartialView("_Example");
      }
      return View();
  </code></pre>
  
  <p>but since the MVC3 is all about conventions and that everything is reconfigurable, I would like to able to write</p>
  
  <pre><code>    if (Request.IsAjaxRequest())
      {
          return PartialView();
      }
      return View();
  </code></pre>
  
  <p>and still load the "_Example.cshtml" if it's a partial view.
  I name "_Something.cshtml" all my partial views anyway so wouldn't it be cleaner if I could just call PartialView(); ?</p>
  
  <p>Please tell me that this is possible. And tell me how.</p>
  
  <p>EDIT:</p>
  
  <p>I still want to be able to make the partialviews different from views, so switching the masterpage would be enough for only a few cases.</p>
  
  <p>I would like to do something like overloading the default path to look for partialviews, like:</p>
  
  <pre><code>PartialViewLocationFormats = new[] {  
      "~/Views/{1}/_{0}.ascx",               
  }; 
  </code></pre>
  
  <p>but this affect PartialView("Example") to use _Example.cshtml too, which is undesirable.</p>
  
  <p>EDIT:</p>
  
  <p>An other thing I tried is to overload the controller's PartialView() and PartialView(object model) methods, but they cannot be overridden neither can I find a proper way to find which action were they called from.</p>