I have an area named adpan in my mvc site with following route config:
context.MapRoute(
"adpan_clinics",
"adpan/DoctorClinics/{doctorObj}/{controller}/{action}/{clinicObj}",
new { action = "Index", Controller = "Clinics", clinicObj = UrlParameter.Optional }
);
context.MapRoute(
"adpan_default",
"adpan/{controller}/{action}/{obj}",
new { action = "Index", Controller = "Dashboard", obj = UrlParameter.Optional }
);
I use T4MVC for routing. Everything works fine until I want to route back from adpan_clinics to adpan_default using action link.
Scenario) I have following urls:
1st url) http://localhost/adpan/Doctors/Index
2nd url) http://localhost/adpan/DoctorClinics/doctor1/Clinics/index
I can redirect to 2nd url with an action link on 1st url's view like this:
@Html.ActionLink("Manage Clinics", MVC.adpan.Clinics.Index().AddRouteValues(new { doctorObj = item.Url }))
But, when redirecting back to 1st url using following action link, I face url appending problem:
@Html.ActionLink("Back to Doctors", MVC.adpan.Doctors.Index())
This action link gives me the following bad url instead of 1st url(Although the page loads correctly!):
bad url) http://localhost/adpan/DoctorClinics/doctor1/Doctors
NOTE: I've also tried this without T4MVC and specifying null values in action link parameters as follow, but still getting the bad url:
@Html.ActionLink("Back to Doctors", "Index", "Doctors", null, null)
I'm just working in adpan area with 2 routes.
I would appreciate any solution and if possible, the reason for getting the correct view from that bad url.