title: ASP.NET MVC Clean way to inject partial view from action
body: <p>I have an app with many widgets and their content depends on the user requesting specific route. Simply put: if widget action is requested, its content must be rendered, otherwise it's empty. Consider routes/actions like this:</p>
  
  <ul>
  <li>~/MyApp/Index -> without model; app HTML, without any widgets</li>
  <li>~/MyApp/Foo/{id} -> uses FooModel; if ModelState is valid, returns
  Index HTML with injected partial view of Foo's widget to div#foo;
  otherwise redirects to Index.</li>
  <li>~/MyApp/Bar/{id} -> same as Foo, but different model and widget</li>
  </ul>
  
  <p>My foo action :</p>
  
  <pre><code>public ActionResult Foo(string id) {
      if (ModelState.IsValid) {
          var response = FooService.GetData(id);
          // Inject Foo widget to Index
      }
      return RedirectToAction("Index");
  }
  </code></pre>
  
  <p>I know that it is possible to use ViewBag or other means to send variables and using the condition to decide whether to render partial view or not. But... there should be a better way to do this, right?</p>