Scott
Scott

Reputation: 91

MVC Routing ambiguous actions

Multiple controller types were found that match the URL. This can happen if attribute routes on multiple controllers match the requested URL.

public class my1Controller: Controller
[Route("path/{param1}", Name = "test1")]
public ActionResult myaction1(string param1)

public class my2Controller: Controller
[Route("path/{param2}", Name = "test2")]
public ActionResult myaction2(string param2)

Is there anyway of getting around this? For historical SEO I need to have two similar urls that have a different single string param.

Upvotes: 2

Views: 249

Answers (1)

Yishai Galatzer
Yishai Galatzer

Reputation: 8862

Your URLS are identical, there is no way to distinguish between them, and both controllers/actions match. That is because the parameter name has no value in picking between the two routes

You could use inline constraints applied to the param1 and param2 to help routing pick one of them. Or make sure "path" is different

Upvotes: 2

Related Questions