views:

50

answers:

1

I have 2 urls /Data and /Data/{month}/{day}/{year}.

I've created two routes

   routes.MapRoute(
        "Data_Name",                                   
        "Data",
        new { controller = "Data", action = "DataForAnyDate" }   
    );

    routes.MapRoute(
        "DataFullDate",                                
        "Data/{month}/{day}/{year}",                        
        new { controller = "Data", action = "DataForSpecificDate"}   
    );

when I go to /Data, it all works, and view I see is Views/Data/DataForAnyDate and controller is Data.DataForAnyDate. When I go to /Data/12/29/2009 I want same asp page (same view), but filled with data from specific date, thus I use Data.DataForSpecificDate controller. But issue is that mvc keeps looking for my view in Views/Data/DataForSpecificDate and I want it to look in Views/Data/DataForAnyDate.

Is there a way to tell Data.DataForSpecificDate to go into Views/Data/DataForAnyDateview, or is there some other way to solve this problem?

Thanks

--MB

+3  A: 

In the DataForSpecificDate method of your DataController, specify the view by ending with Return View("DataForAnyDateview")

Since your controller code is not posted here, I'm making the assumption u might just have Return View(); in which case it would look for a view with the same name as the method.

lcrepas
I use ViewModels, so they do: return View(viewModel);
Massive Boisson
So return View("DataForAnyDateview", viewModel); seems to work, so thanks
Massive Boisson