title: .NET Core MVC - Different Controllers, Different HTML In Same View-page, Different Scripts
body: <p>I am developing an application using <strong>.NET Core MVC</strong>. I have different data-sets that loads through request to the controllers. For example, I have this controller methods:</p>
  
  <ul>
  <li>localhost/Election</li>
  <li>localhost/Election/2008</li>
  <li>localhost/Election/2008/United_States</li>
  </ul>
  
  <p>And the methods that works for this parameters are in <strong>ElectionController</strong> like:</p>
  
  <pre><code>public async Task&lt;IActionResults&gt; Index(){ 
  
     // Return a list of data
  }
  
  
  public async Task&lt;IActionResults&gt; Index(string year){ 
  
     // Return a list of data
  }
  
  
  public async Task&lt;IActionResults&gt; Index(string year, string location){ 
  
     // Return a list of data
  }
  </code></pre>
  
  <p>What happens is, these methods return some data in the same view page <strong>/ Election/ Index</strong>. </p>
  
  <p>But I want to use different <strong>JavaScript codes</strong> and <strong>different html</strong> to represent this data-sets in the /Election/Index view page. Let's consider a <strong>scenario</strong>:</p>
  
  <ul>
  <li><p>If user enters : <strong>localhost/Election</strong> Then application is Rendering some <strong>table</strong> and using <strong>/script/jsCode1.js</strong></p></li>
  <li><p>When user enters into: <strong>localhost/Election/2008</strong> Then application is Rendering some <strong>cards</strong> and using <strong>/script/jsCode2.js</strong></p></li>
  <li><p>When user enters into: <strong>localhost/Election/2008/United_States</strong>
  Then application is Rendering some <strong>charts</strong> and using <strong>/script/jsCode3.js</strong></p></li>
  </ul>
  
  <p>How should I approach to solve this problem?</p>