I wrote my routes like this.
routes.MapRoute(
name: "AdminECommerce",
url: "Admin/ECommerce/{controller}/{action}/{id}",
defaults: new { id = UrlParameter.Optional },
namespaces: new []{ "AdminEcommerce.Controllers" }
);
routes.MapRoute(
name: "ECommerce",
url: "ECommerce/{controller}/{action}/{id}",
defaults: new { id = UrlParameter.Optional },
namespaces: new []{ "Ecommerce.Controllers" }
);
routes.MapRoute(
name: "User",
url: "Plugin/User/{controller}/{action}/{id}",
defaults: new { id = UrlParameter.Optional },
namespaces: new []{ "User.Controllers" }
);
routes.MapRoute(
name: "UserRegistration",
url: "Plugin/UserRegistration/{controller}/{action}/{id}",
defaults: new { id = UrlParameter.Optional },
namespaces: new []{ "UserRegistration.Controllers" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
When I want to use RedirectToAction
from one Action to other Action in the same Controller It Redirects Somewhere else.
For Example, I want it to redirect me to
Plugin/UserRegistration/Register/Register
But,It Sends me to
Admin/ECommerce/Register/Register
I Have to mention that my controllers are in other libraries.
What is wrong with my code?
Update: Controller Registration
public ActionResult Register()
{
ViewBag.securityQuestions = _dataRepository.GetContext().User_SecurityQuestion;
return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult RegisterNewUser(User_User model, FormCollection collection)
{
try
{
// register new user
...
return RedirectToAction("Register");
}
catch
{
// making error messages
...
return RedirectToAction("Register");
}
I also tried this,
return RedirectToAction("Register","Registration");
It doesn't work.