In the current version, a try-catch block is the only way to catch
missing/illegal parameters.
If you want to specify default values for missing parameters, what you
can to is use several page methods.
For example, you can have :
void ShowProjectInfo(int projectId)
{
ShowProjectInfoWithDetails(projectId, false);
}
void ShowProjectInfoWithDetails(int projectId, bool includeDetails)
{
// Do the real thing
}
Note: method overloading is not supported by PageMethods, as indicated
in the FAQ (
http://metasapiens.com/PageMethods/faq).
If you want to hide the method names in the URL (the PageMethod
parameter), you should use URL rewriting (see the FAQ).
Of course this can get annoying if you have a lot of optional
parameters.
Another option is to use reference types (such as strings) for your
parameters. As long as the ParamRequired attribute is not applied to
such a parameter, a missing value for this parameter won't be signaled
by an ArgumentException.
Of course, you then have to cast the parameters to their real type
(e.g. from string to int or bool).
As a conclusion: there is no specific support for what you're trying
to achieve, but you should be able to do it with what is provided.
Of course, you can also suggest an improvement to the source code to
be integrated in a later release :-)
Fabrice