views:

74

answers:

1

When I click run on my vs2008 to try out a page it tries to load

http://localhost:14092/Views/Employee/Index.aspx

which should be

http://localhost:14092/Employee/Index

or http://localhost:14092/

How do I add these 2 routes? (I want to know how to do both so I can swap them as desired.

Here's my current routing code:

 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 = "" }  // Parameter defaults
        );


    }
+2  A: 

Have you changed the debugging options to always start at a specific page? If not, go to your project's properties and change the debugging properties to have your debugger to always start the project at the root page. I typically also tell it to always use the same port -- so that I can use FF or IE and the history works to give me the right URL. See Steven Walther's article on how to run an ASP.NET MVC application for alternatives.

tvanfosson
that's helpful for debugging in general, but I'd like to know how to do the 2 routing options also.
Maslow
hmm I'm trying this and it's not working so far. I tried setting Default.aspx and Views/Employee/Index.aspx and this setting did not override the fact that I had the Index.aspx page up when I hit run
Maslow
You don't set it to the ASPX page that you want. You set the url to the route you want shown. I would suggest that you set it to a single page, and perhaps, use the technique described in the article so that your browser doesn't close (I actually just open FF manually to the url/port) and navigate to the action you are interested in debugging. Then you can just reload after restarting the debugger.
tvanfosson
alright, so it works, for having a default page to load to, but I'd like to set the routes so that I can restore the ability to go straight to the page I'm workin on
Maslow
That sounds hard to me since "pages" in MVC correspond to controller actions, not to particular views. You could have many actions that render the same view and actions that render multiple views. How is the debugger supposed to figure out which of the actions to run or views to render. More over the url may contain data that needs to be passed to the view. How is this data supposed to be supplied? Short of asking every time the debugger starts up, I don't know how the IDE would do it. I think it's best to leave the browser open at the url you are working with and refresh when debugging.
tvanfosson
There's no way to route /Views/* to /* ? or anything that would 404 to /?
Maslow