C
C#11mo ago
Duchess

✅ ASP.NET Web APP trouble saving data help?

i have the project mostly correct and the other two pages ive created are properly saving data and displaying them but i somehow can't get this one to do the same. not sure if im missing something because i've been staring at the screen to long or what.
15 Replies
MasterSubarashii
MasterSubarashii11mo ago
you probably have to do that
MasterSubarashii
MasterSubarashii11mo ago
so it knows its a post request also you are returning nothing to the page so it won't fill the model also your button does not send request to that post method there are actually more things to say but imo, follow a tutorial first
Duchess
Duchess11mo ago
thanks ill go through and try this appreciate it
Angius
Angius11mo ago
That is a lot of red underlines
Duchess
Duchess11mo ago
@ZZZZZZZZZZZZZZZZZZZZZZZZZ there’s only that many because I copied it into word to get a better screenshot and it doesn’t recognize anything
Angius
Angius11mo ago
Why would you copy it to Word lmao Screenshot the editor Or better yet, post actual $code
MODiX
MODiX11mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat If your code is too long, post it to: https://paste.mod.gg/
Duchess
Duchess11mo ago
appreciate it heres the create page and index pages not sure if the error is here. visual studio doesnt recognize any errors but im unable to save anything after submitting it, or have it show in the list. https://paste.mod.gg/mswtjtiegybo/3
BlazeBin - mswtjtiegybo
A tool for sharing your source code with the world!
Duchess
Duchess11mo ago
for reference here is my create and index pages for the student section which does work as expected, saving and displaying the data. https://paste.mod.gg/rdwebeftjvve/1
BlazeBin - rdwebeftjvve
A tool for sharing your source code with the world!
Duchess
Duchess11mo ago
@ZZZZZZZZZZZZZZZZZZZZZZZZZ not sure if you could lend a hand now but heres the code
Angius
Angius11mo ago
So, what happens, actually? Did you go through the code with the debugger? Also, what is FinalProject_2202331.Models.Exam? It's possible that creating it with just a single property filled is invalid (although that should show an error)
Duchess
Duchess11mo ago
@ZZZZZZZZZZZZZZZZZZZZZZZZZ after I open the form and input data then click create it just reloads the page, rather then on say the students page after clicking create it redirects to the index page which shows the list and it populates the data I just inputted. “FinalProject…” I thought this was just stating that it uses my exam model in my project. Visual studio shows no errors though. I’m actually rather new to coding is the the debugger within VS? I can zip up my entire project if that is more helpful so you could see the entire thing but not sure what’s best place to then upload that
Angius
Angius11mo ago
So, I assume, this code gets executed:
Angius
Angius11mo ago
I'd like you to confirm that with the debugger Also, since the modelstate is invalid, there will be specific model state errors You should either use the debugger to read them from ModelState, or you can try to display them somewhere Or even log them to console https://stackoverflow.com/questions/1352948/how-to-get-all-errors-from-asp-net-mvc-modelstate
Accord
Accord11mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.