Home > Software engineering >  ASP .Net Can't find newly added views
ASP .Net Can't find newly added views

Time:03-08

I am using a template and I am properly navigating with the browser locally to the Home/About view that was already created.

However, if I add another view, for example About2 (copy of About, only changing the ViewBag Title), I am unable to access to it, and I am getting a 404 error The resource cannot be found instead.

I am not quite familiar to ASP, so am I missing any routing or basic step in order to route to the new added view?

enter image description here

CodePudding user response:

One reason this could occur is if you don't have a start page set under your web project's properties. So do this:

Right click on your mvc project Choose "Properties" Select the "Web" tab Select "Specific Page" Assuming you have a controller called HomeController and an action method called Index, enter "home/index" in to the text box corresponding to the "Specific Page" radio button.

Now, if you launch your web application, it will take you to the view rendered by the HomeController's Index action method.

(or)

Simply, you could also open one of the controllers in your project and then hit on F5 or Ctrl F5.

What's happening now is that, you are currently in your /Views/home/Index.cshtml view and you just hit on F5 or Ctrl F5. In an mvc project, you cannot open a file w/ .cshtml extension directly as IIS cannot understand that. The controller is supposed to return a matching view from within the action method.

As a side-note also check if you have MVC 3 installed correctly. If my answer doesn't help, I am sorry.

  • Related