C
C#6mo ago
HDNedww

✅ Error submitting answers: Exception of type 'Microsoft.AspNetCore.Components.NavigationException'

The submit answers button works kind of but for some reason it doesnt save the participant chosen or written answers, can someone find the problem in this code? ive tried many solutions, especially using chatgpt but it does not help.https://paste.mod.gg/voaresitdbol/0
BlazeBin - voaresitdbol
A tool for sharing your source code with the world!
8 Replies
SleepWellPupper
SleepWellPupper6mo ago
Can you share the exception message from that NavigationException?
HDNedww
HDNedwwOP6mo ago
Executed DbCommand (65ms) [Parameters=[@p0='?' (DbType = Int32), @p1='?' (DbType = Int32), @p2='?' (DbType = Int32), @p3='?' (DbType = DateTime2), @p4='?' (DbType = Int32), @p5='?' (Size = 1000), @p6='?' (DbType = Int32), @p7='?' (DbType = Int32), @p8='?' (DbType = Int32), @p9='?' (DbType = DateTime2), @p10='?' (DbType = Int32), @p11='?' (Size = 1000), @p12='?' (DbType = Int32), @p13='?' (DbType = Int32), @p14='?' (DbType = Int32), @p15='?' (DbType = DateTime2), @p16='?' (DbType = Int32), @p17='?' (Size = 1000), @p18='?' (DbType = Int32), @p19='?' (DbType = Int32), @p20='?' (DbType = Int32), @p21='?' (DbType = DateTime2), @p22='?' (DbType = Int32), @p23='?' (Size = 1000), @p24='?' (DbType = Int32), @p25='?' (DbType = Int32), @p26='?' (DbType = Int32), @p27='?' (DbType = DateTime2), @p28='?' (DbType = Int32), @p29='?' (Size = 1000), @p30='?' (DbType = Int32), @p31='?' (DbType = Int32), @p32='?' (DbType = Int32), @p33='?' (DbType = DateTime2), @p34='?' (DbType = Int32), @p35='?' (Size = 1000), @p36='?' (DbType = Int32), @p37='?' (DbType = Int32), @p38='?' (DbType = Int32), @p39='?' (DbType = DateTime2), @p40='?' (DbType = Int32), @p41='?' (Size = 1000), @p42='?' (DbType = Int32), @p43='?' (DbType = Int32), @p44='?' (DbType = Int32), @p45='?' (DbType = DateTime2), @p46='?' (DbType = Int32), @p47='?' (Size = 1000), @p48='?' (DbType = Int32), @p49='?' (DbType = Int32), @p50='?' (DbType = Int32), @p51='?' (DbType = DateTime2), @p52='?' (DbType = Int32), @p53='?' (Size = 1000), @p54='?' (DbType = Int32), @p55='?' (DbType = Int32), @p56='?' (DbType = Int32), @p57='?' (DbType = DateTime2), @p58='?' (DbType = Int32), @p59='?' (Size = 1000)], CommandType='Text', CommandTimeout='30'] SET IMPLICIT_TRANSACTIONS OFF; SET NOCOUNT ON; MERGE [Participant_Responses] USING ( VALUES (@p0, @p1, @p2, @p3, @p4, @p5, 0), (@p6, @p7, @p8, @p9, @p10, @p11, 1), (@p12, @p13, @p14, @p15, @p16, @p17, 2), (@p18, @p19, @p20, @p21, @p22, @p23, 3), (@p24, @p25, @p26, @p27, @p28, @p29, 4), (@p30, @p31, @p32, @p33, @p34, @p35, 5), (@p36, @p37, @p38, @p39, @p40, @p41, 6), (@p42, @p43, @p44, @p45, @p46, @p47, 7), (@p48, @p49, @p50, @p51, @p52, @p53, 8), (@p54, @p55, @p56, @p57, @p58, @p59, 9)) AS i ([QuestionID], [QuizID], [SelectedAnswerID], [Timestamp], [UserID], [WrittenAnswer], _Position) ON 1=0 WHEN NOT MATCHED THEN INSERT ([QuestionID], [QuizID], [SelectedAnswerID], [Timestamp], [UserID], [WrittenAnswer]) VALUES (i.[QuestionID], i.[QuizID], i.[SelectedAnswerID], i.[Timestamp], i.[UserID], i.[WrittenAnswer]) OUTPUT INSERTED.[ResponseID], i._Position; Participant responses saved successfully. Navigation to quizcompleted page... Error submitting answers: Exception of type 'Microsoft.AspNetCore.Components.NavigationException' was thrown. this error was in the console
SleepWellPupper
SleepWellPupper6mo ago
Line 186: navigationManager.NavigateTo("/quizcompleted"); Do you have a page / an endpoint mapped to /quizcompleted ?
HDNedww
HDNedwwOP6mo ago
yes, but for some reason it cant find the page but the link is correct but also the submit answers button does submit respones to the participant_responses, so the HandleValidSubmit task works, but not NavigateToQuizCompleted the submitted responses though do not save the selected answer id nor written answers, they just have NULL values there @page "/quizcompleted" @inject NavigationManager navigationManager <h2>Quiz Completed</h2> <p>Thank you for participating in the quiz!</p> <button @onclick="ReturnToActiveQuizzes">Return to Active Quizzes</button> @code { private void ReturnToActiveQuizzes() { navigationManager.NavigateTo("/activequizzes"); } } this is the quiz completed page
SleepWellPupper
SleepWellPupper6mo ago
Have you set an interactive render mode for the takequiz page? e.g. on Routes or App?
HDNedww
HDNedwwOP6mo ago
No i dont think i have routes.razor:<Router AppAssembly="typeof(Program).Assembly"> <Found Context="routeData"> <AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" /> <FocusOnNavigate RouteData="routeData" Selector="h1" /> </Found> </Router> app.razor:<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <base href="/" /> <link rel="stylesheet" href="bootstrap/bootstrap.min.css" /> <link rel="stylesheet" href="app.css" /> <link rel="stylesheet" href="Viktorina.styles.css" /> <link rel="icon" type="image/png" href="favicon.png" /> <HeadOutlet /> </head> <body> <Routes /> <script src="_framework/blazor.web.js"></script> </body> </html> if i set render mode in app.razor, none of the pages open ok i fixed it i use render mode for takequiz and it works, thank you bro
SleepWellPupper
SleepWellPupper6mo ago
$close
MODiX
MODiX6mo ago
If you have no further questions, please use /close to mark the forum thread as answered
Want results from more Discord servers?
Add your server