---
title: "Different ways of Navigation in MVC"  
description: "Navigation is way of redirecting from one page to another. There are several way that I have explained below  1-HyperlinkIt is use with standard ancho"  
author: "Manish Kumar"  
published: 2017-01-21  
updated: 2018-03-17  
canonical: https://www.mindstick.com/blog/11280/different-ways-of-navigation-in-mvc  
category: "asp.net mvc"  
tags: ["mvc"]  
reading_time: 2 minutes  

---

# Different ways of Navigation in MVC

[Navigation](https://www.mindstick.com/blog/62/different-navigation-in-asp-dot-net) is way of redirecting from [one page](https://www.mindstick.com/forum/118/problem-in-display-content-of-one-page-to-another-page) to another. There are several way that I have explained below\

**1-Hyperlink** **–**It is use with [standard](https://www.mindstick.com/articles/23223/naming-convention-or-coding-standard) [anchor tag](https://www.mindstick.com/blog/437/read-html-file-and-convert-its-content-no-to-link-as-a-anchor-tag) which is use in html.

**2-ActionLink****-** it is use to go to given action in the specific [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc). If no controller is given then it will look for the action inside the current controller

**Ex-1**

**Syntax-**

```
@Html.ActionLink(text_to_display,actionName)Use@Html.ActionLink("greetuser","Welcome")    Ex-2syntax  @Html.ActionLink("text ","action","controller")Use  @Html.ActionLink("user login","Login","Acount") Supplying
querystring with Hyperlink  @Html.ActionLink("user login","Login","Acount", new
{id=1234}, null)
```

**3-RouteLink****-**It is the same as action link but it does not provide the facility for action name, controller name we have to specify it as follows:

**Ex**

```
@Html.RouteLink("Greetings", new {action="welcome"})    @Html.RouteLink("Greetings",new
{action="Welcome", Controller="account"})4-response.redirect()-  Response.Redirect("Controller/action")       
Response.Redirect("/action")
```

Generally written inside the controller or in the view

**4-[RedirectToAction](https://www.mindstick.com/forum/2342/how-to-redirecttoaction-with-anchor-tag-in-mvc)()-** This tells Mvc to [redirect](https://www.mindstick.com/forum/2005/radio-button-redirect) to specified action instead of rendering HTML or rendering a view

**Ex**

```
public ActionResult login()    {        return RedirectToAction("login2");    }    public void login2()    {        Response.Write("welcome");    }
```

**5-RedirectToRoute()**

This [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) is used to link or navigate to the route defined by the user. This will be define in the routeConfig file.It will search for the registered route and then it will use the [parameters](https://www.mindstick.com/articles/87/passing-parameters-in-c-sharp) defined in the route to navigat. This function can be useful for directly navigating to the different route apart from the route from where our home controller is.

The routes are defined in the routeConfig.cs file inside the [RegisterRoutes](https://www.mindstick.com/forum/12655/registerroutes-not-working-in-mvc5) function

![Different ways of Navigation in MVC](https://www.mindstick.com/blogs/c8549e58-1965-4836-a994-1c9bfc023f9c/images/115e2b52-6153-45cb-bcf8-6cb3b23cb985.png)\

\

```
using System;using
System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using System.Web.Routing; namespace Demo{                                                  public class RouteConfig    {        public static void RegisterRoutes(RouteCollection routes)        {            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");            routes.MapRoute(                "MyRoute",//Route Name                "Acount",//Url                new {Controller="Account", action="Login"} //Parameter default            );             routes.MapRoute(                name: "Default",                url: "{controller}/{action}/{id}",                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }            );        }    }}
```

**Now inside the controller we do the following**

```
public ActionResult Test()    {        return RedirectToRoute("MyRoute");    }
```

## *Note-*

**1**-Return View doesn’t make a new request and url in the browser’s address bar is updated with the generated url by mvc.

**2**-Return Redirect also makes a new requests and ur in the browser’s address bar is updated, but you have to specify the full url to redirect

**3**-Between RedirectToAction and Redirect best practice is to use redirectToAction for anything dealing with your application

---

Original Source: https://www.mindstick.com/blog/11280/different-ways-of-navigation-in-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
