Display a "Back" button, only if there is a back (MVC)

asp.net-mvc, asp.net-mvc-2, c#, visual-studio-2010

Solution

@if(Request.UrlReferrer != null)
{
    <a class="bottomNav" onclick="history.go(-1); return false;" href="#">Back</a><br />
}

Problem

Right now I'm using `<a class="bottomNav" onclick="history.go(-1); return false;" href="#">Back</a><br />` But then it will always be displayed, even when the "back" button won't lead anywhere. How can I check if there is a "back" before displaying the button? I wanted to check the action and controller, for example: `if(ViewContext.Controller.ValueProvider.GetValue("controller").RawValue != "Home")` But it is not accurate because I still need the "back" sometimes

Original source