C#C
C#13mo ago
morry329#

✅ always gets the invalid data received

I have been creating a simple CRUD app with the ASP.NET. My update function does not work as expected: the save button triggers the error message "invalid data received" ; somehow the model reference is considred null on clicking the save button

//clicking the save btn prompts this method to work
public async Task<IActionResult> Update(ListingProjects updatedUserModelRef)
    {
        if (updatedUserModelRef == null || updatedUserModelRef.ListingName == null)
        {
            if (Request.Headers["X-Requested-With"] == "XMLHttpRequest")
            {
                return Json(new { success = false, message = "Invalid data received." }); //however it always falls into this invalid message..
            }
            return NotFound();
        }


could anyone kindly advice me on why the save button does not save the user input as expected? the full code here https://pastebin.com/4C2aYF78
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Was this page helpful?