I have a simple entity... Student... I need to have two edit views for the student... One for Administrators and one for the student themselves...
I have a HOME controller, and a STUDENTS controller... The "Students" controller is where all the ADMIN Work occurs... Nothing wrong there...
In the HOME controller I copied over the Controller methods for Edit {get and post} from the Student Entity... On my "Index" page of the HOME controller I simply have a search dialog for students to look up their StudentID... My entity (SQL) table is as follows...
studentid {autoincrement SQL primary key}
studentidentivication {int }
firstname... blah, blah, blah...
My initial search looks up the studentidentification (their personal id provided by the school), and calls the HomeController "EDIT"... When the View comes up at the head of the Razor page I have validated that the student entity (model) is full and accurate... I then attempt to save the entity, and in the HTTP post EDIT of the HOME controller ModelState.IsValid() is returning false... After looking closely, the model that was received by the controller is invalid because the studentid (sql identity primary key) is "0"...
1) the student Model is correct at the header of the razor page...
2) the form in the Razor Page has a valid <input type="hidden" asp-for="Studentid"> nested at the very top of the form...
3) this is a direct copy of the controller methods and view from the Student Controller which works great and does not have this problem.
4) I have a 1.2 .NET Core application that was built with the same technique and does work!!!
Can anyone provide some guidance on this?
Thanks in advance,
Stew Basterash