I have a pretty basic RESTful WCF service in C# as follows.
public SchoolList[] GetSchoolList(string authenticationToken, string term, string stateID, string schoolTypes)
{
if (!TokenAuthenticator.Authenticate(authenticationToken, out marketPlaceIdInner))
{
//throw new ApplicationException(Constants.InvalidAuth); //**line 1**
}
try
{
SchoolList[] returnedschoolList = schoolManagementCacheServiceClient.GetSchoolSuggestions(term, schoolTypes, stateID).ToArray<SchoolList>();
return returnedschoolList;
}
finally
{
schoolManagementCacheServiceClient.Close();
}
}
It is functioning well, what I want to achieve is when the control reaches line 1 I want to return a simple error string and HTTP Status code to be 403 i.e. forbidden.
How can I achieve it in minimal code? I have referred other code samples and that are too big and bit complex.