13

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 ?

1 Answer 1

23

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.

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

9 Comments

With your solution, it always opens the home page (localhost). I'd like VS to open the controller of my current view : if I work on the /Views/MyController/Index.aspx file, I'd like it to open localhost/MyController
Why are your controllers inside your Views folder? Normally, controllers live in the Controllers folder.
Actually, I'm not sure that this is even doable. What you want is to open a route that corresponds to a controller action not a view. The view is chosen by the controller. Opening up a particular view absent the associated route information makes no sense.
Sorry for the misunderstanding, my controllers live in the Controllers folder. Here is another example : when I work on the /Views/Products/Index.aspx file, which is the View of the ProductsController controller, I want VS to open localhost/Products
@tvanfosson, I understand but I thought that in ASP.NET MVC, if no action is indicated, it executes the Index() action of the controller ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.