I'm trying to fetch the current page from my shared layout in .net mvc app so that I can load a different favicon icon for the 2 different pages.
I've tried something like following:
@if (Request.Url.AbsoluteUri.ToString().ToLower().Contains("/Analyze/Index"))
{
<link rel="icon" type="image/png" href="/favicon.png" />
}
But this doesn't works...
How can I fetch the current controller and view that user is on while browsing the website so that I can load this favicon in his/her browser?
You can get your current controller name & action method name from your RouteData dictionary.