question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When asp-if evaluates to false, the content is still generated, and suppressed after

See original GitHub issue

Say we invoke a partial view such as: <partial name="_PersonSummary" model="Model.PersonSummaryInfo" asp-if="Model.PersonSummaryInfo is not null" />

The partial view assumes that its supplied model is not null, so a null reference exception happens if it’s invoked when PersonSummaryInfo is null. A standard @if block around the <partial> prevents that, but asp-if doesn’t because the partial is still invoked.

Please close the issue if this is expected behaviour or if there’s no way around it other than sticking with an @if block, or changing the partial to cope with a null model.

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
danielgreencommented, Dec 15, 2022

@DamianEdwards Works a treat thanks.

Updated the tag helpers defined in my own codebase to set the Order and use the SuppressedByAspIf extension method in line with this change. So it’s handy you made that public 😄

1reaction
DamianEdwardscommented, Dec 14, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why there is no deep dornish masterplan : r/asoiaf
Even in his supposedly most badass moment, he still sounds weak. Is it a surprise that his plan goes horribly wrong later? That's...
Read more >
Recovery Time of Platelet Function After Aspirin Withdrawal
The platelet function was gradually normalized 72 hours after drug withdrawal. This suppression was consistent with the results reported for ...
Read more >
Chapter-by-Chapter Analysis: Tyrion V, ACOK
When trying to evaluate how good a job Tyrion's doing as Hand, I think we have to acknowledge that (unlike his father) he...
Read more >
Alas, poor Wallace: A Review of Infinite Jest | Three Pound Brain
[3] It makes no more sense reviewing a novel absent its particular communicative context than it does evaluating conversations with your mom, ...
Read more >
How to Build Your Own ASP-based System?!
Answer Set Programming, or ASP for short, has become a popular and sophisticated approach to declarative problem solving.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found