Cyril Gupta
Cyril Gupta

Reputation: 13723

Doesn't ASP.Net MVC Differentiate URLs on number of arguments?

Somehow I had the impression that ASP.Net differentiates URLs based on the number of arguments too. But it doesn't seem to work in my project.

Consider the following function prototypes

public PartialViewResult GetMorePosts(string param1, string param2, string param3, int param4, int param5) AND public PartialViewResult GetMorePosts(string param1, string param2, string param3, int param4)

I thought if my URL had one extra argument it should resolve to the second function... Instead I am getting an ambiguous URL error.

Why?

Upvotes: 1

Views: 147

Answers (2)

Levi
Levi

Reputation: 32828

ASP.NET MVC doesn't support action method overloading based on method signature. For a discussion of this and workarounds, see this post.

Upvotes: 1

Mark Dickinson
Mark Dickinson

Reputation: 6633

You need to make sure that the route table has the url wit the least arguments first, otherwise the one with more arguments will hide the rest.

Upvotes: 1

Related Questions