Bonjour � tous,
J�ai g�n�r� un bug en faisant ceci :
Afficher le d�tail d�un article avec dont l�identifiant est 1 voir lien
http://localhost:1234/Contenu/Articles/Details/1
Puis remplacer son num�ro par 5 qui ne correspond � l�identifiant d�un article, voir lien
http://localhost:1234/Contenu/Articles/Details/5
ET �� donne :
PAR ANALOGIE :
Sequence contains no elements
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Sequence contains no elements
Source Error:
[No relevant source lines]
Comment faire pour que m�me si on saisie dans l�URL un num�ro ne correspondant pas � l�identifiant d�un �l�ment dans la base �� n�affiche pas une telle erreur ?
Server Error in '/' Application.
Sequence contains no elements
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Sequence contains no elements
Source Error:
Line 126: CurrentPage(page);
Line 127: ViewData["State"] = state;
Line 128: OpenCategoryId(id);
Line 129: return View(db.Categories.Single(c => c.Id == id));
Line 130: }
Source File: C:\Intranet 30 fev\Intranet\Areas\Contenu\Controllers\ArticlesController.cs Line: 0
Merci.
Partager