Redirect user to another page from controller action method in ASP.NET MVC

How to redirect the user to another page from controller action method?

To redirect the user to another page (either external or internal), we can use Redirect method like below.
public ActionResult Index()
        {
            return Redirect("http://www.itfunda.com"); // redirects to external url
         }

public ActionResult Index()
        {
            return Redirect("/FilesModels/Create"); // redirects to internal url
         }
Remember that to redirect to external url, we need to provide complete url starting with http. For internal redirect, url can be provided from root of the application.

No comments:

Post a Comment

How to register multiple implementations of the same interface in Asp.Net Core?

 Problem: I have services that are derived from the same interface. public interface IService { } public class ServiceA : IService { ...