Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

excluding child action of a child action failes #46

Open
mahdi87gh opened this issue Sep 21, 2015 · 13 comments
Open

excluding child action of a child action failes #46

mahdi87gh opened this issue Sep 21, 2015 · 13 comments

Comments

@mahdi87gh
Copy link

Hi
I have a child action for creating my footer which loads data from database. And I am loading it like this in my Layout.chtml

@Html.Action("CreateFooter", "Home", true)

In CreateFooter action I call another child action for displaying page visit status which shouldn't be cached and needs to display fresh data. So in my CreateFooter.chtml

@Html.Action("GetStatus", "VisitCounter", new { Address = "PV-Home -> Index" },true)

But things in my footer gets messed up. some part of footer which is right after this line of code, repeats before whole footer!! If i change it to this line

@Html.Action("GetStatus", "VisitCounter", new { Address = "PV-Home -> Index" })

Nothing gets messed up but the visit status data wo'nt be fresh anymore.

In Home controller , CreateFooter has dounut attribute
In VisitCounter controller , GetStatus has'nt dounut attribute

Please kindly help me.

@moonpyk
Copy link
Owner

moonpyk commented Sep 21, 2015

Can you provide me a simple MVC demonstrating the issue ?

@mahdi87gh
Copy link
Author

ok here is one example
if you take a good look, in footer we should have two lines of "some other information about copyrights" but in second page load which is when the page is cached, we have 4 lines.
https://drive.google.com/file/d/0B3YNJ8ZQzEClY3pmekxMeUVnN28/view?usp=sharing

@mahdi87gh
Copy link
Author

And I found out the second child action gets called just once! which should display fresh data everytime but it won't.
Thanks

@migig
Copy link

migig commented Sep 24, 2015

Are you doing any of this in an actionfilter?

If so, I had a similar problem and discovered it's because the actionfilter was being called twice, if it is on an action which calls a child action. You can avoid that by checking filterContext.IsChildAction.

@mahdi87gh
Copy link
Author

Thanks man,
But no I'm not. If you download the sample project you'll see.

@migig
Copy link

migig commented Sep 25, 2015

@mahdi87gh From your description it sounds like what I posted is correct. You need to somehow check for IsChildAction, and return if that is the case, else you will get two calls to the child action. See here.

@mahdi87gh
Copy link
Author

Dear @migig As I mentioned before, I'm not getting two calls at all, and I'm not using any action filter. You can see it for yourself in the sample project.
Thanks anyway

@migig
Copy link

migig commented Sep 26, 2015

@mahdi87gh Your post implied that you are getting two calls, because you said that the markup is repeated. Maybe put a breakpoint in the innermost child action and double check?

@mahdi87gh
Copy link
Author

@migig I did that (putting breakpoints on every action) before and NO I'm not getting two calls!!! and markup is repeated that's why I posted here!

@migig
Copy link

migig commented Sep 26, 2015

That's weird... 😦 Try StackOverflow....

@migig
Copy link

migig commented Sep 26, 2015

@mahdi87gh See this

@mahdi87gh
Copy link
Author

@migig Thanks
I did what i had to. I put database driven markup inside CreateFooter action and other markup to _layout.chtml

@migig
Copy link

migig commented Sep 26, 2015

Cool 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants