title: MVC - Can I display Title and Massage on 1 View by 2 different Controllers?
body: <p>I'm new to MVC and also new to Stackoverflow. I'm not working with any Database but I simply want to display Title and Massage on 1 View by 2 different Controllers. I want in my Index.cshtml file the <code>@ViewBag.Title</code> display from HomeController.cs file and the <code>@ViewBag.Massage</code> display from <code>OtherController.cs</code> file. How can I do this and how to reference or attach <code>OtherController.cs</code> to <code>Index.cshtml</code>? Please don't tell me that I'm asking for something like how to attach stylesheet to html but it's not possible with MVC.</p>
  
  <p>If it's really not possible then please tell me how to do this by partial views with having a _Layout.cshtml file. Because I don't want to write too much in my View Files.</p>
  
  <p>Thank You in Advance!</p>
  
  <p><strong>RouteConfig.cs</strong></p>
  
  <pre><code>routes.MapRoute(
                  name: "Default",
                  url: "{controller}/{action}/{id}",
                  defaults: new { controller = "Home",
                                  action = "Index",
                                  id = UrlParameter.Optional
                                }
                 );
  </code></pre>
  
  <p><strong>HomeController.cs</strong></p>
  
  <pre><code>public ActionResult Index()
          {
              ViewBag.Title = "";
              return View();
          }
  </code></pre>
  
  <p><strong>OtherController.cs</strong></p>
  
  <pre><code>public ActionResult Index()
          {
              ViewBag.Massage = "";
              return View();
          }
  </code></pre>
  
  <p><strong>Index.cshtml</strong></p>
  
  <pre><code>&lt;title&gt;@ViewBag.Title&lt;/title&gt;
  
  &lt;p&gt;@ViewBag.Massage&lt;/p&gt;
  </code></pre>