title: Display custom error message in ASP .Net 5, MVC 6
body: <p>I have one method which is calling api method. That api method contains SQL statements of insert, update, delete. But when any error is thrown from stored procedure, How to display in front as error message. I am using ASP .NET 5 and MVC 6. My method is like below :</p>
  
  <pre><code>[HttpPost]
  [AllowAnonymous]
  [ValidateAntiForgeryToken]
  public async Task&lt;IActionResult&gt; Method(Model model)
  {
      string url = ConfigurationSettingHelper.BaseUrl + "apiurl";
  
      using (var client = new HttpClient())
      {
          client.BaseAddress = new Uri(url);
          client.DefaultRequestHeaders.Accept.Clear();
          client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
  
          HttpResponseMessage response = await client.PostAsJsonAsync&lt;Model&gt;(url, model);
  
          if (response.IsSuccessStatusCode)
          {
              var data = await response.Content.ReadAsStringAsync();
              var Msg = Newtonsoft.Json.JsonConvert.DeserializeObject&lt;string&gt;(data);
  
              if (!string.IsNullOrEmpty(Convert.ToString(Msg)))
              {
                  //Here code to display error message.
              }
          }
      }
      return View();
  }
  </code></pre>
  
  <p>Help me to display Msg variable string message on page.</p>
  
  <p>Thank You</p>