Home Alternative request uri in c# (cshtml)
Reply: 1

Alternative request uri in c# (cshtml)

R.J.G
1#
R.J.G Published in 2017-11-14 07:57:57Z

I looking for help with C# (cshtml) if statement, to display paragraph on only homepage site, like in php.

<?php
    if ($_SERVER['REQUEST_URI']=='/')
    {
        echo('<p>something</p>');
    }
?>   

Thanks in advance

Werner
2#
Werner Reply to 2017-11-14 11:25:51Z

A Block in Razor always starts with @.

@if (Request.Url.ToString() == "/")
{
    <p>something</p>
}

See:

  • Razor Syntax (MSDN)
  • Request.Url (MSDN)
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.528952 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO