title: ASP. NET Core Call Web API from Razor View
body: <p>I build a Razor View for my web app layout. In my Layout I want to get a user's photo in my layout. But, the problem is how to get the user's photo from the web api and return it to Razor View</p>
  
  <p>Here's my API code:</p>
  
  <pre><code>[HttpGet("employee-photo/{employeeId}")]
  public async Task&lt;IActionResult&gt; GetEmployeePhoto(string employeeId)
  {
      var employeeIdClaim = this.UtilityService.GetEmployeeIdClaim(User);
      if (employeeId != employeeIdClaim)
      {
          return null;
      }
      var employeePhoto = await this.FileStorage.GetEmployeePhoto(employeeId);
      var name = employeeId + ".jpg";
  
      return File(employeePhoto, "image/jpg", name);
  }
  </code></pre>
  
  <p>and here's my Razor View</p>
  
  <pre><code>&lt;a class="nav-link dropdown-toggle text-white" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"&gt;
     &lt;img src="@Url.Action("/api/v1/blob/employee-photo/18060001")" /&gt;&lt;span class="hidden-xs"&gt;@User.Claims.Where(Q =&gt; Q.Type == "FullName").Select(Q =&gt; Q.Value).FirstOrDefault()&lt;/span&gt;
     &lt;i class="fa fa-caret-down"&gt;&lt;/i&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p><code>api/v1/blob</code> is my API path, I just not write it all of the other code here </p>
  
  <p>Can i get photo(image) from my API to my Razor View? How? Thanks</p>