[c#] ASP.NET MVC 3 - redirect to another action

I want to redirect the Index action of the Home controller to another controller's action and nothing else. My code is thus:

    public void Index()
    {
        //All we want to do is redirect to the class selection page
        RedirectToAction("SelectClasses", "Registration");
    }

Right now, this just loads a 0 kB blank page and does nothing. I have a feeling it has something to do with that void return type, but I don't know what else to change it to. What's the issue here?

This question is related to c# asp.net-mvc redirect

The answer is


You will need to return the result of RedirectToAction.


Should Return ActionResult, instead of Void


return RedirectToAction("ActionName", "ControllerName");

You have to write this code instead of return View(); :

return RedirectToAction("ActionName", "ControllerName");

Examples related to c#

How can I convert this one line of ActionScript to C#? Microsoft Advertising SDK doesn't deliverer ads How to use a global array in C#? How to correctly write async method? C# - insert values from file into two arrays Uploading into folder in FTP? Are these methods thread safe? dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Best way to "push" into C# array

Examples related to asp.net-mvc

Using Lato fonts in my css (@font-face) Better solution without exluding fields from Binding Vue.js get selected option on @change You must add a reference to assembly 'netstandard, Version=2.0.0.0 How to send json data in POST request using C# VS 2017 Metadata file '.dll could not be found The default XML namespace of the project must be the MSBuild XML namespace How to create roles in ASP.NET Core and assign them to users? The model item passed into the dictionary is of type .. but this dictionary requires a model item of type How to use npm with ASP.NET Core

Examples related to redirect

React-Router External link Laravel 5.4 redirection to custom url after login How to redirect to another page in node.js How to redirect to an external URL in Angular2? How to redirect to a route in laravel 5 by using href tag if I'm not using blade or any template? Use .htaccess to redirect HTTP to HTTPs How to redirect back to form with input - Laravel 5 Using $window or $location to Redirect in AngularJS yii2 redirect in controller action does not work? Python Requests library redirect new url