diff --git a/ImageBoardServerApp/Pages/Basic/ThreadPage.razor b/ImageBoardServerApp/Pages/Basic/ThreadPage.razor index 8f860ac..f5e7d69 100644 --- a/ImageBoardServerApp/Pages/Basic/ThreadPage.razor +++ b/ImageBoardServerApp/Pages/Basic/ThreadPage.razor @@ -19,30 +19,30 @@ @code { + [Parameter] [Required] public string boardName { get; set; } - + [Parameter] [Required] public string threadId { get; set; } - + private PostData post; protected override async Task OnInitializedAsync() { - try - { - post = await PostsRepository.getPostByIdAsync(int.Parse(threadId)); - } - catch (FormatException fe) - { + if (!int.TryParse(threadId, out _)) NavigationManager.NavigateTo("/notfound"); - return; - } - if(post.Board != boardName) + post = await PostsRepository.getPostByIdAsync(int.Parse(threadId)); + + if (post == null) NavigationManager.NavigateTo("/notfound"); - if(post == null) + + if (post.Board != boardName) + NavigationManager.NavigateTo("/notfound"); + if (post == null) NavigationManager.NavigateTo("/notfound"); } + } \ No newline at end of file