ASP.MVC error "cannot find resource"

Asked

Viewed 3,523 times

1

I’m starting in ASP.NET and tried to create a test app.

When running by Visual Studio I have the print error.

I created a standard MVC 5 project, created the controller the model and the view each in its proper location.

inserir a descrição da imagem aqui


EDIT

How would I access then considering the design structure according to the image below:

inserir a descrição da imagem aqui

3 answers

2

IIS does not serve the files .cshtml of your application. You access the pages of your application by entering the routes mapped to it. You will see how to configure these routes at some point in your learning, but for now just know that by default they are created like this:

nome do `controller` (sem o sufixo "controller")/nome do método no controller

Note that to serve HTML, you must have a view with the same method name.

So if you have one controller called "fooController" and a view calling for index, what you seek will be in:

/foo/index

1

You never access the View directly.

The correct is to access Action of each Controller. For example, if I have one Controller called ProdutosController and a Action calling for Index, the route will be:

http://localhost:53710/Produtos/Index

There are also default routes. They are usually set in the file RouteConfig.cs, directory App_Start.

A project configured from scratch back as default HomeController as Controller and Index as Action. You can change it if you want.


EDIT

Like there’s only one Controller created, you can access it using:

http://localhost:53710/Categorias

Or

http://localhost:53710/Categorias/Index

1

You are trying to access something not accessible, the code of view.

Note that in the folder Views there is a file web config., he’s responsible for blocking this.

The correct is to access Controller/Action, whereas the controller be it HomeController and the action is Index, the address would be:

http://localhost:53710/Home/Index


Considering the posted image, you must access (if there is an action Index in the controller)

http://localhost:53710/Categorias/Index

Browser other questions tagged

You are not signed in. Login or sign up in order to post.