Redirect back to Previous Page without losing original data

I have trouble preserving the original data by redirecting the same page when my custom error handling is executed in the controller.
Assume that I have a web page call Create.cshtml.
In that create webpage, I have a few form control which require the user to enter class code but the class code cannot be duplicated.
Assume that the user entered a class code that is existed in the system, my system should redirect back to Create.cshtml and pass error message (E.g. ViewBag.error = “Class Code duplicated”) and simulatenously .
But my current implementation does not revert back the original content/data after redirect.

Error when using api call to send post values to controller and mapping them with a dto

I have two webpages, the first has a dropdown that allows the person to select a project & a button. When the button is submitted, it takes them to the manage users webpage and sends the Projectname to the webpage as well. The manage users webpage allows the person to assign a user to the project they selected on the previous webpage. There is a button as well, and when submitted it sends an api call with post values to my controller. The controller accepts a dto and then binds these values to the AssignUserDto. It then finds the entity associated w/ the dto username, and then maps the values from the dto to the entity so that the user has a Projectname associated with it.

Post action not working in controller but working in another controller

I have a project that allows users to create a new project. The UI has some textboxes and a submit button. It sends data through a POST request to an api call, which then creates a new project entity in the database. I deleted my migrations and then added a new migration since I wanted to fix some code, but now the post action no longer works. I see the following error message in the console –