Welcome to ASP.NET Guild

Be sure to come back often and tell others. If you have any tips, tricks, examples, please email them to me at chris.williams@techguilds.com and I will post them. Check out our ASP.NET QuickStart and C# QuckStart Libraries. Below is my latest articles.

Sunday, February 28, 2016

MVC RedirectToAction Explained for Beginners

RedirectToAction should be simple but sometimes they are confusing to beginners.  There are 3 ways to call RedirectToAction
  1. If you are already on a page within a controller you can use the shortest one which is only the caption and the action.

    eg. RedirectToAction("MyActionName")
  2. If you are referencing another controller or you want to include parameters.

    IMPORTANT: It may seem redundant but you need to list the action name twice. Notice Login is listed twice. 

    eg. RedirectToAction("Login", new RouteValueDictionary(new { controller = "Account", action = "Login", returnUrl = "/PersonalizedLearn" }));
I hope this clears up how RedirectToAction calls work.

If you have any questions feel free to email me at chris.williams@readwatchcreate.com



Are you a .NET Developer or Contractor interested in working with Sitecore or Dynamics CRM?

Apply for our Mentorship Program. If accepted, we will mentor you on Sitecore and provide you with project to help you build your skills and make some money at the same time. If you are interested send your resume with details on why you want to work with Sitecore or Dynamics CRM to: Chris Williams - chris.williams@techguilds.com or Dennis Augustine - dennis.augustine@techguilds.com We look forward to working with you to achieve your goals.