Throw 404 when blog post fails to load.
This commit is contained in:
parent
40e8899368
commit
6c905f177f
2 changed files with 9 additions and 5 deletions
|
@ -30,9 +30,13 @@ namespace Website.Controllers
|
|||
|
||||
public async Task<IActionResult> Entry(string url)
|
||||
{
|
||||
var post = await _repo.GetPostByUrlAsync(url);
|
||||
var model = new BlogPostViewModel(post);
|
||||
return View(model);
|
||||
try {
|
||||
var post = await _repo.GetPostByUrlAsync(url);
|
||||
var model = new BlogPostViewModel(post);
|
||||
return View(model);
|
||||
} catch (InvalidOperationException e) {
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue