title: Load image from webmethod
body: <p>I used to work in an mvc project and I had used the following code to load an image:</p>
  
  <p><strong>cshtml</strong></p>
  
  <pre><code> &lt;img src="@Url.Action("GetImage", new { imageUrl =
   @asset.ImageUrl })" /&gt;
  </code></pre>
  
  <p><strong>C#</strong></p>
  
  <pre><code>public void GetImage(string imageUrl )
          {
  
              try
              {
                  using (WebClientExtension client1 = new WebClientExtension())
                  {
                      byte[] imageBytes = client1.ExecuteRequest(imageUrl );
                      if (imageBytes.Count() == 0)
                          throw new Exception();
                      HttpContext.Response.ContentType = "image/jpeg";
                      HttpContext.Response.OutputStream.Write(imageBytes, 0, imageBytes.Length);
                  }
              }
              catch (Exception)
              {
                  String FilePath;
                  FilePath = Server.MapPath("/Images/no_image.png");
                  byte[] imageBytes = System.IO.File.ReadAllBytes(FilePath);
                  HttpContext.Response.ContentType = "image/jpeg";
                  HttpContext.Response.OutputStream.Write(imageBytes, 0, imageBytes.Length);
              }
  
          }
  </code></pre>
  
  <p>Everything worked fine, and now my problem is use this in an ascx page. Obviously,<code>@Url.Action("GetRenditionImage", new { renditionUrl =
       @asset.RenditionUrl })</code> wont work in ascx. How can I call a web method to achieve this?</p>