Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Remain on page after post

$
0
0

This is a really stupid question, but I'm not sure how to do the following:

I have a web app (ASP .Net Core 1.1 MVC) which, when the user clicks a delete button, calls a delete action on a Web API.

        // GET: Property/Delete/5
        public async Task<ActionResult> Delete(int id)
        {
            if (!ModelState.IsValid)
                return BadRequest(ModelState);

            HttpResponseMessage responseMessage = await client.DeleteAsync(url);
            if (responseMessage.IsSuccessStatusCode)
            {
                RedirectToAction("Index");
                return Ok();
            }
            return View("Error");
        }

Basically, the user is on the Index page, then he clicks "Delete" next to a record, and I want it to delete the record, but remain on the Index page (but it should refresh the Index page to show the record is gone). Obviously what I'm doing above is wrong, but I'm not sure hwo to do it...


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>