开发者

why would i get a different views when called from different controller actions in asp.net-mvc

开发者 https://www.devze.com 2022-12-31 17:11 出处:网络
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.

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 Fitnes开发者_开发知识库sByTab() 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("


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.


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("

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号