Month: November 2018

Conditional but static text in ASP.net Razor Pages

On a recent work project I wanted to display some static text on an ASP.net Razor Page, but only if a certain field in the database was empty or whitespace. So, if the entity’s title wasn’t set in the database, display a generic title in the web front-end.

I tried using a normal if … else block but had trouble with it because the text was supposed to be inside all inside of the HTML title element and Razor Pages was getting confused (as was I) when I tried to include static text inside the if block and  C# code inside the else block.

Continue reading →

Posted by Anthony in Learnings