views:

462

answers:

1

I'm running Visual Studio 2008 sp1 on Win7, with MVC2 RTM installed.

I created a new MVC2 project using the wizard and am unable to debug specific pages. With webforms and even MVC1, I was able to sit on a View page, hit F5, and then have the integrated web server in VS2008 start on the page I was working on. Very handy for building up app logic.

When I try this now I get a "The resource cannot be found" error page.

I retried this just now with a stock new MVC2 Web Application project. Here are the steps I took after creating the new project to reproduce:

  1. Open up project settings. Under the Web subtab, set the Start Action to "Current Page". Leave all the other settings as is.
  2. Open one of the views up (e.g. Account/Register.aspx)
  3. Hit F5 to debug the project
  4. Note that the browser window which displays shows the error message "The resource cannot be found".

The link I saw in my browser for this run was: http://localhost:49471/Views/Account/Register.aspx

I did some googling and found suggestions related to ensuring all HTTP server pieces were installed. I double checked and made sure that "HTTP Errors" and "HTTP Redirection" were both installed.

If I leave the project setting as it was originally, set to "Specific Page" with nothing in the text box, then routing works and I always get the default home page. I'm hoping this isn't the only option.

Thanks!

+1  A: 

Generally, the "resource cannot be found" (which is an HTTP 404) in ASP.NET MVC indicates some kind of routing problem.

Setting the Start Action to a page (any page) is probably why you're having this problem. AFAIK, this will always cause a 404 because MVC projects don't do pages, they do Actions.

Try clearing the Start Action- you should then see the Index action/view "page" come up when you run the project. Going forward, if you want to go to a particular Controller Action on startup, enter the [ControllerName]/[Action] in the Start Action without an .aspx page name.

Dave Swersky
tks for the quick response. I thought I had this working in my old MVC1 project, but with your comment above maybe not. I spend most of my time in webforms and am working off an on (mostly off) with some MVC projects. So, when you're working on a view and you want to see it in a browser, you always debug into the main app page and then alter the URL line in the browser (or navigate directly) to the page you want?
schefdev
You can still "jump" to an Action using the Start Action, such as http://mysite.com/someController/someAction/someParameterJust don't include a page name.
Dave Swersky
Beautiful, thanks! I can work with that no problem.
schefdev