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
An action result is what a controller action returns in response to a browser request. The ASP.NET MVC framework supports several types of action results including: ViewResult - Represents HTML and markup. EmptyResult - Represents no result.
To return a view from the controller action method, we can use View() method by passing respective parameters. return View(“ViewName”) – returns the view name specified in the current view folder (view extension name “. cshtml” is not required. return View("~/Views/Account/Register.
Razor is a markup syntax that lets you embed server-based code into web pages using C# and VB.Net. It is not a programming language. It is a server side markup language. Razor has no ties to ASP.NET MVC because Razor is a general-purpose templating engine. You can use it anywhere to generate output like HTML.
@if(Request.UrlReferrer != null)
{
<a class="bottomNav" onclick="history.go(-1); return false;" href="#">Back</a><br />
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With