I have a partialview in _Layout.cshtml that I only want to display for certain urls. My first thought was in my partial I would use a string as the model @model String . In the actionmethod that is called I would return this return PartialView("_MyPartial", new string{Request.FilePath}); In the partial I would have an if block wrapping my outer div that would check the model to see if the url it contained was the url that can display the partial.
I don't like this way because I would have to hardcode the url in if block check
@if( Model == "/Test/Home")
{
<div>
Just an example
</div>
}
What would be the best way to do this?
Thanks