title: how to get data by Id and view bag to view MVC
body: <p>i have View Named Index     i want to pass data get by GuidId. in Model and View Bag ... after enter Id how do this </p>
  
  <pre><code>public IActionResult Index()
  {
  
      return View();
  }
  
  public async Task&lt;IActionResult&gt; GetDS(Guid Id)
  {
        var url = string.Empty;           
        url = ApiEndpoint.serviceUrl + ApiEndpoint.GetDS + Id;
        var data = await ApiService.GetAsync&lt;DSModel&gt;(url).ConfigureAwait(false);
  
        url = ApiEndpoint.serviceUrl + ApiEndpoint.GetDSL + Id;
        var data2 = await ApiService.GetAsyncCollection&lt;DSLDetails&gt;(url).ConfigureAwait(false);
        ViewBag.DSL = data2;
        return View("Index", data);
  }
  </code></pre>
  
  <p>html error shows in HTML Side</p>
  
  <pre><code>@foreach (var item in @ViewBag.DSL)
  {
      &lt;tr&gt;
           &lt;td&gt;
              @item.Name
           &lt;/td&gt;
  }
  </code></pre>
  
  <blockquote>
    <p>ERROR  NullReferenceException: Object reference not set to an instance of an object.</p>
  
  <pre><code>AspNetCore.Views_Division_Index.ExecuteAsync() in Index.cshtml
  +
              @foreach (var item in @ViewBag.DSL)
  </code></pre>
  </blockquote>