Hello everyone, I'm starting my study in ASP.NET but I'm having trouble compiling the code through IIS, error appears
Application Server Error '/'.
The resource can not be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could not be removed, its name changed, or is temporarily unavailable. Examine the URL and make sure it is spelled correctly.
Requested URL: / Categories / View
Version Information: Microsoft .NET Framework Version: 4.0.30319; ASP.NET Version: 4.7.7160.0
If someone can help you thank you right away.
categoriaController
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TesteAprendizagem1.Models;
namespace TesteAprendizagem1.Controllers
{
public class CategoriasController : Controller
{
private static IList<Categoria> categorias = new List<Categoria>()
{
new Categoria()
{
CategoriaId=1,
Nome="Notebooks"
},
new Categoria()
{
CategoriaId=2,
Nome="Monitores"
},
new Categoria()
{
CategoriaId=3,
Nome="Impressoras"
},
new Categoria()
{
CategoriaId=4,
Nome="Mouses"
},
new Categoria()
{
CategoriaId=5,
Nome="Desktops"
}
};
// GET: Categorias
public ActionResult Index()
{
return View();
}
}
}
RouteConfig
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace TesteAprendizagem1
{
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 = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
}
Category
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace TesteAprendizagem1.Models
{
public class Categoria
{
public int CategoriaId { get; set; }
public string Nome { get; set; }
}
}
View
@model IEnumerable<TesteAprendizagem1.Models.Categoria>
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>View</title>
</head>
<body>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.Nome)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Nome)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.CategoriaId }) |
@Html.ActionLink("Details", "Details", new { id=item.CategoriaId }) |
@Html.ActionLink("Delete", "Delete", new { id=item.CategoriaId })
</td>
</tr>
}
</table>
</body>
</html>