2

I have no idea why this error is occurring after debugging the project even though the codes are default.

Controller

public class HomeController : Controller { // // GET: /Home/ public ActionResult Index() { return View(); } } 

View

 @{ Layout = null; } <!DOCTYPE html> <html> <head> <title>Index</title> </head> <body> <div> Hi </div> </body> 

Somehow or rather, after debugging, the Requested URL is always /Views/Home/Index.cshtml but accessing Home via browser is fine. (http://localhost:58323/home)

I googled and solution hints that the problem lies in global. But thats weird, I dont remember making any changes to it.

Global

 public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); } 

Appreciate any help. Thank you

3 Answers 3

5

I think you just have your visual studio settings set so that the view is set to the start page. Right click on the project and go to properties, then to the web tab. Is the 'specific page' radio button selected with 'Views/Home/Index.cshtml' set as the value? Change it to use a start url. Personally I prefer not to have the debugger start up a browser and use Don't open a page.

Sign up to request clarification or add additional context in comments.

1 Comment

hi, am also getting same problem, but when i changr it to use a start url,and then save i got an error msg "the start URL specified in not valid"
4

Right click your web project -> Properties -> Web

check that you have the start action set to Specific Page with no value in the field.

My guess is that you have the start action set to current page.

Comments

0

This error might even cause if the hierarchy of the folder structure is incorrect in Views folder. If you are adding views by right-click on Views folder.The new view added might be incorrectly placed in the folder hierarchy.

The way to troubleshoot the problem is: Consider a view named index.ascx which is supposed to be linked to a Controller named HomeController. Under the Views folder there should be a folder name Home (relating to the Controller) and the index.ascx should reside in Home folder.

The best possible way to add view is to right-click just beside the public method which will show a Create View option in context-menu.If you crate view in such manner then folder hierarchy is automatically created.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.