Reputation: 59
I'm getting an intermittent error when I "run" a MVC app from Visual Studio. Here is the error:
The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Views/DDF/Edit.vbhtml
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225
My default routing is set up as follows:
Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
routes.MapRoute( _
"Default", _
"{controller}/{action}/{id}", _
New With {.controller = "DDF", .action = "Index", .id = UrlParameter.Optional} )
End Sub
Normally, when I start the app, the browser tries to display the url http://localhost:49999/ and the DDFController's Index action is executed and rendered. Occasionally, VS tries to open the the following url:
http://localhost:49999/Views/DDF/Edit.vbhtml
I don't know why it is trying to display the edit action, or why it adds ".vbhtml" to the url, but it fails with the error.
So, Why is Visual Studio using the wrong url (with the vbhtml extension) and how can I fix it?
Upvotes: 3
Views: 3922
Reputation: 8595
When you use visual studio to edit a web application (web forms) there's an option which will load up the page you currently have in the foreground in the editor (its under the properties of the web application, the web tab, and called Start Action: Current Page).
It's pretty crude and just starts up internet explorer (assuming this is your browser) with a path to the location of the file you're editing.
Since this isn't how MVC works, I wouldn't recommend using this option, and instead change it to "Specific Page" or some other option which loads the correct page each time you start
Martin
Upvotes: 6
Reputation: 89140
You're trying to show the view directly, which can't be done.
Visual Studio sometime passes the wrong URL to the browser when you have a view open in it. Don't worry about it and just change the URL to one that you know works.
Upvotes: 1