Reputation: 2253
I want to generate URL like.. It should include two IDs with employer and job including.
I am confused and have no idea about it. I have a controller Employer
.
http://localhost/Employer/[employerID]/job/[jobid]
Upvotes: 3
Views: 819
Reputation:
routes.MapRoute(
"EmplyerJob", // Route name
"Employer/{empid}/job/{jobid}",
new { controller = "Employer",
action = "Job" }
);
I have made a few changes to Xander's answer. I don't think you'll want to use parameters here, as this will throw off other routes to other controllers/action methods. If you use the hard-coded "Employer"
and "job"
strings, you will be narrowing down what routes are analyzed by this route.
Also, you can't have an optional parameter before a required parameter.
Upvotes: 6