Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug with Visual Studio, wrong URL on ASP.NET MVC

I just created a ASP.NET MVC project in VS2008.

When I press F5 to debug the current view in my browser, it open the URL of the ASPX file :

http://localhost/Views/MyController/Index.aspx

instead of :

http://localhost/MyController

How to make it open the good URL ?

like image 861
Olivier Payen Avatar asked Feb 01 '09 16:02

Olivier Payen


People also ask

How does MVC handle wrong URL?

If those URLs don't include a controller or action method name, then you can provide the missing information through default values on your routes. But if those URLs include an incorrect action or controller name, then ASP.NET MVC will simply return one of the standard HTTP error codes.

How do I debug MVC application in Visual Studio?

To debug a MVC solution:Under Debug > Choose Attach to process (Or ctrl + alt + p ) In the process list, choose the w3wp.exe or iisexpress.exe process (depending on your project type), and click attach. Wait for visual Studio to load all relevant symbols referenced by your project (this might take a while).

How do I fix unable to start debugging on web server?

Open your project properties and make sure that the project is configured to connect to the correct Web server and launch URL. (Open Properties > Web > Servers or Properties > Debug depending on your project type.) If that does not work or you are debugging remotely, follow steps in Check your IIS Configuration.


1 Answers

You've got start action set to Current Page in the Web tab of the project properties.

Change it to Specific Page and leave the specific page text box blank.

Edit: from the comments attached to this answer we've established that what would be desirable is for VS to heursitically determine that given that the current page in the editor is "Views/Products/Index.aspx" we would like VS to start a debugging session at /Products.

This is too much to be asking of VS right now.

The alternative might seem to always be starting from the root and navigating in.

However you can edit the Specific Page text box to the path you'd like it to start. If you are debugging the above view then entering "Products" in the text box would probably be the closest you'd get to the goal.

You'd have to keep changing the content of the Specific Page text box each time you want to repeatedly test a different view.

like image 71
AnthonyWJones Avatar answered Sep 22 '22 08:09

AnthonyWJones