Note that there are some explanatory texts on larger screens.

plurals
  1. PORedirection to different controller method
    primarykey
    data
    text
    <p>I need to redirect a request to another controller. So basically I have www.MyDomain.com/SomeParameter. I need to read this parameter value from URL and then redirect to another controller for further processing. For this purpose I have two controllers in my project Home and Employee as follows.</p> <pre><code>public class HomeController : Controller { public ActionResult Index(string ID) { if (!string.IsNullOrEmpty(ID)) { string EmployeeAccountNumber = GetEmployeeNumberFromID(ID); RedirectToAction("Employee", "Index", EmployeeAccountNumber); } return View(); } private string GetEmployeeNumberFromID(string ID) { return "Alpha"; } } public class EmployeeController : Controller { // // GET: /Employee/ public ActionResult Index(string id) { return View(); } } </code></pre> <p>I then added Routing is defined as follows in Global.asax</p> <pre><code>public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); routes.MapRoute( "EmployeeManagement", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Employee", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); } </code></pre> <p>As you can see in the Index method of HomeController class, I want to Redirect to my EmployeeController, however, the breakpoint I set in EmployeeController.Index never get hit. Am I doing something wrong here? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload