Bonjour,
lorsque j'essaie de démarrer mon programme, celui-ci m'affiche une erreur, comme quoi il ne trouve pas ma page.
Voici le message d'erreur:
Voici l'arborescence de mon programme:La ressource est introuvable.
Description : HTTP 404. La ressource recherchée (ou l'une de ses dépendances) a peut-être été supprimée ou renommée ou bien elle n'est plus disponible temporairement. Vérifiez l'URL ci-après et assurez-vous qu'elle est correcte.
URL demandée: /Views/My/Index.cshtml
Views
=====> _Layout.cshtml
=====> My
========>_produits.cshtml
========>AboutUs.cshtlml
========>ContactUs.cshtml
========>Index.cshtml
...
Voici mon fichier Index.cshtml:
Le fichier RouteConfig.cs:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 @model LearningTennisClub.Models.Produit @{ ViewBag.Title = "Home"; Layout = "~/Views/_LayoutPage.cshtml"; } <h2>This is my home page</h2> @Html.Partial("~/Views/My/_produit.cshtml", Model)
Mon fichier MyController.cs:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; namespace LearningTennisClub { public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "My", action = "Index", id = UrlParameter.Optional } ); } } }
Pouvez-vous me dire d'où vient l'erreur?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using LearningTennisClub.Models; namespace LearningTennisClub.Controllers { public class MyController : Controller { // GET: My public ActionResult Index() { Produit produit = new Produit() { NomProduit = "Produit 175296", CouleurProduit = "Rouge", MarqueProduit = "Souregi", PoidsProduit = "5kg", TypeProduit = "Electronique" }; return View(produit); //return View(); } public ActionResult AboutUs() { return View("AboutUs"); } public ActionResult ContactUs() { return View("ContactUs"); } public ActionResult Facebook() { return View("Facebook"); } public ActionResult Twitter() { return View("Twitter"); } } }
Merci d'avance de votre réponse.
Mumu27
Partager