2
I started doing a project from scratch using MVC 4 from VS 2012. As I opted for an Empty, I can’t get the view started. I took the route:
routes.MapRoute(
name: "Operador",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Operador", action = "Index", id = UrlParameter.Optional }
);
But when I give an F5, it gives me that mistake:
Erro de Servidor no Aplicativo '/'.
Não é possível encontrar o recurso.
Descrição: HTTP 404. O recurso que você está procurando (ou uma de suas dependências) não pôde ser removido, seu nome foi alterado ou está temporariamente indisponível. Examine o URL e certifique-se de que está digitado corretamente.
URL solicitada: /
Informações sobre a Versão: Microsoft .NET Framework Versão:4.0.30319; Versão do ASP.NET:4.0.30319.34249
In my URL it is: http://localhost:60975/
i add after the bar(/) the controller name and keep giving me error that did not find the view Index. How do I fix this?
public class OperadorController : Controller
{
//
// GET: /Operador/
public ActionResult Index()
{
return View();
}
}
View
@{
ViewBag.Title = "Operador";
}
<h2>Operador</h2>
O Package.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AutoMapper" version="4.0.4" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="2.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="4.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="4.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="4.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="4.5.6" targetFramework="net45" />
</packages>
Global.asax
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
}
The Route.config
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Operador",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Operador", action = "Index", id = UrlParameter.Optional }
);
}
}
MeuController
exists?– Leonel Sanches da Silva
@Gypsy omorrisonmendez, yes he exists and created a view for him. I’m just not sure is how to call him.
– pnet
Weird. You can put the Controller and View in your question, please?
– Leonel Sanches da Silva
I edited the question
– pnet
You can also put the
packages.config
on the question? Apparently everything is right with the structure.– Leonel Sanches da Silva
It’s also okay. I want to check the
Global.asax.cs
, if possible.– Leonel Sanches da Silva
It’s all right. I don’t know what else it could be.
– Leonel Sanches da Silva
@Ciganomorrisonmendez, I click with the right button on top of my Action and I give Go to View and I get the following message: Unable to find matching view. I deleted the view and I reset it and it’s still the same thing, which means he can’t find the view, now I don’t know why.
– pnet