I have this method in WebApi
[IHttpActionResult]
[Get]
public void GetSome(P1, P2 ....... Pn)
{
...///
}
Just curious:
Any ideas, what is the maximum number of parameters allowed by WebApi for this method ?
I have this method in WebApi
[IHttpActionResult]
[Get]
public void GetSome(P1, P2 ....... Pn)
{
...///
}
Just curious:
Any ideas, what is the maximum number of parameters allowed by WebApi for this method ?
You mean technically or practically? :p
The C# method parameter limit is 65,535. Most browsers only support an URL of 2000 to 4000 characters. Depending on the consumer of your API, there might be some restrictions there as well.
But most importantly: what are you trying to do? Seriously?
You're creating an API, simple methods that are easy to understand should be your main goal. I'm not sure a method with 65000 parameters would be anywhere near simple.
To me this sounds like step 1 of a walk down "OMG kill this code" lane :)
There are few similar Q & A
around Internet
and Stack overflow
. Which is asked to know the C# Method maximum number of parameters
. The same will be applicable in your case as well.
Cases:
16383
parameters can be
compiled, ran, and called (!)16384
or more parameters can be
compiled, but running such a program throws an unstated exception.StackOverflowException
being thrown.csc.exe
giving a compile-time error, stating
that the resulting expression is too long or complex to handle
.Note:
Those numbers depend on the architecture of the operating system
and the memory of the computer
.
From Browser side it may vary. It may be allow less or more than this count.
Similar Q & A:
C# Method Maximum Number of Parameters
Acceptable Parameters Count for a C# Method
Passing required and less number of parameters to the Method will be the best coding practice.