title: How to display alert message box in asp.net core mvc controller?
body: <p>I want to display alert message box when the account model is invalid.
  How should i gonna do this in controller in Asp.Net Core MVC?
  Here is my Controller's code</p>
  
  <pre><code>    [HttpPost]
      public IActionResult Index(Account model)
      {
          if (model.ID != null &amp;&amp; model.PassWord != null)
          {
              using (var db = new AccountDBContext())
              {
                  var account = db.Account.FirstOrDefault(
                                  a =&gt; a.ID.Equals(model.ID) &amp;&amp; a.PassWord.Equals(model.PassWord)
                                );
  
                  if(account != null)
                      return RedirectToAction("Index", "Main");       
  
              }
              //I want to display error msg box...here like "Check ID or PW".
              ModelState.AddModelError("", "Error");
  
          }
  
  
          return View();
      }
  </code></pre>
  
  <p>I searched the way but there is no "Page" identifier or "Response.write()" Method in this controller class....
  How should i gonna do?</p>
  
  <p>p.s
  The way that i checked model's validation like that is right way?
  (I used a model and check it's partial properties, instead using view model )</p>