views:

24

answers:

2

I have 2 different controller actions. As seen below, one calls the same view as the other one. The fitness version has a bunch of jquery ui tabs.

    public ActionResult FitnessByTab(string tab, DateTime entryDate)
    {
        return View("Fitness", GetFitnessVM(DateTime.Today.Date));
    }


    public ActionResult Fitness()
    {

        return View(GetFitnessVM(DateTime.Today.Date));
    }

    private FitnessVM GetFitnessVM(DateTime dt)
   {
        FitnessVM vm = new FitnessVM();
        vm.Date = dt;
       // a bunch of other date that comes from a database
        return vm;
    }

the issue is that on the action FitnessByTab() the tabs dont load correctly but on the Fitness() it loads fine. How could this be as my understanding is that they would be going through the same code path at that point. As you can see i am hard coded both to the same date to make sure its not a different date causing the issue.

EDIT

Issues has been solved. It was the relative referencing of all my links. I didn't get any issues until i used firebug that highlighted some missing references due to "../../" instead of Url.Content("

A: 

From what you've shown it is difficult to determine from where comes the problem. I think you've missed some important detail. Also why in the title of your question you are talking about redirects? Both actions render the same view, there's no redirect happening here.

If your code really looks like this then you definitely don't need the two actions as the first completely ignores its arguments and indeed the result should be the same. Also how are you calling those actions? Is it the same way?

What's the type returned by the GetFitnessVM method? If it is string then this could be your problem.

Darin Dimitrov
@Darin Dimitrov - GetFitnessVM returns a ViewModel class. I have added a simplified version of the code. When i said redirect, i just meant they call the same view in different ways. I will clarify my question and add some more color
ooo
@Darin Dimitrov - also, just to clarify, i do need two actions. ultimatley i am going to pass in another date but i wanted to keep it simply to figure out why this basic example wasn't working before i added extra complexity
ooo
So how are you calling those actions? GET, POST, AJAX? Did you analyze the returned HTML? Were there any differences?
Darin Dimitrov
@Darin Dimitrov - nothing fancy here. I am just typing in the URL into the browser . .no ajax here . .
ooo
Any differences in the generated HTML? By the way you never said what error message you are getting. Is it some JS error?
Darin Dimitrov
@Darin Dimitrov - here is the crazy thing. at first i saw some of my stylesheets with different relative paths. But then i go and fixed that. I now view page source on both and they are identical but in one jquery ui tabs works and the other it doesn't show the tabs. There is no error, its just that the tabs dont show
ooo
@Darin Dimitrov - i figured it out that it was the relative paths. So even though it was the same HTML it was starting from different directories . . INstead of doing this <script src="../../etc ", i had to change all of my js and css links to this: <script type="text/javascript" src="<%=Url.Content("~/Scripts/fitness/file.js")%>"></script>
ooo
A: 

Issues has been solved. It was the relative referencing of all my links. I didn't get any issues until i used firebug that highlighted some missing references due to "../../" instead of Url.Content("

ooo