@inherits Custom.Hybrid.Razor14
<!-- unimportant stuff, hidden -->
@using ToSic.Razor.Blade;
Working with number URL Parameters When... <!-- unimportant stuff, hidden -->
@{
// This variable is a string, but could be null or empty
var idAsString = CmsContext.Page.Parameters["id"];
// This converts the id parameter to int and takes 0 as fallback
var id = Kit.Convert.ToInt(CmsContext.Page.Parameters["id"], 0);
}
<ul>
<li>
<strong>Raw id from URL:</strong> @idAsString <br>
Equal to string "27": @(idAsString == "27") <br>
Equal to number 27: (would throw error) <br>
</li>
<li>
<strong>Number id from URL:</strong> @id <br>
Equal to string "27": (would throw error) <br>
Equal to number 27: @(id == 27) <br>
</li>
</ul>
<!-- unimportant stuff, hidden -->