How to redirect to Index from another controller?
Use the overloads that take the controller name too...
return RedirectToAction("Index", "MyController");
and
@Html.ActionLink("Link Name","Index", "MyController", null, null)
Redirect to Action in another controller
You can supply the area
in the routeValues
parameter. Try this:
return RedirectToAction("LogIn", "Account", new { area = "Admin" });
Or
return RedirectToAction("LogIn", "Account", new { area = "" });
depending on which area you're aiming for.
ASP.NET MVC RedirectToAction not redirecting to Index of another controller
There is nothing wrong with the route setting the reason it does not include Index
in the URL
because according to default route
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
when you enter /Registration
the route already knows the default action which is index
so it does not add /index
in URL
and about
403.14 forbidden
if you look at this post HTTP Error 403.14 - Forbidden - MVC 4 with IIS Express it could be because you might have a file or folder named Registration
in the project directory
Redirect in MVC controller to another controller not working
Try this-
return RedirectToAction("Index", "Error", new {
ErrorTitle = "Record not Found",
ErrorMessage = "The Product you are looking for is no longer available"
});
You basically need to redirect to the error controller and pass in the params as part of the route. RedirectToAction takes a parameter of RouteValues
Also you do not need "ErrorController", you can just use "Error"
Asp.Net MVC - using RedirectToAction() to go to another controller in a different folder - 2 deep
According to Microsoft documentation, There is a process call View Discovery that search the Views automatically or by specifying the path :
To do this, I think, you have two solutions:
1 - Create Admin folder under the Views, and not under Views/AdminFunctions. by using the below redirection :
1.1 - HomeController
public ActionResult Index()
{
return RedirectToAction("Index", "Admin");
}
1.2 - AdminController
public ActionResult Index()
{
return View();
}
2 - Keep the same hierarchy, and specify the path to locate Index
view for AdminController :
2.1 - HomeController
public ActionResult Index()
{
return RedirectToAction("Index", "Admin");
}
2.2 - AdminController
public ActionResult Index()
{
return View("/Views/AdminFunctions/Admin/Index.cshtml");
}
I hope this will help you fix the issue
Redirecting to Another Controller
Switch the s
and profile
, you have them reversed. RedirectToAction
How can I redirect from a controller with a value to another controller in laravel?
if you want to redirect to named route you can use this:
return redirect()->route('payments.pay', ['orderId' => $order->id]);
if you want generate redirect to controller action you can try this:
return redirect()->action(
'PublicSslCommerzPaymentController@index', ['ordId' => $order->id]]
);
Related Topics
Why Can't C# Use Inline Anonymous Lambdas or Delegates
Differencebetween Iequalitycomparer<T> and Iequatable<T>
Why Value-Types Are Stored Onto Stacks
Asmx Web Service How to Return JSON and Not Xml
Digital Signature in C# Without Using Bouncycastle
Get All Associate/Composite Objects Inside an Object (In Abstract Way)
Difference Between Destructor, Dispose and Finalize Method
Log4Net Logging of Two Different Levels to Two Different Appenders for the Same Logger
How to Convert a File into Byte Array in Memory
Run the Current Application as Single Instance and Show the Previous Instance
Mvc: Where to Put Business Logic
How to Use Acrylic Accent in Windows 10 Creators Update
Additional Setup in Visual Studio Installer Projects
The JSON Value Could Not Be Converted to System.Int32
Parallel.For(): Update Variable Outside of Loop
How Would I Sort a List of Files by Name to Match How Windows Explorer Displays Them