—Judgment unanimously reversed, on the law, and petition reinstated. Memorandum: An appeal from a preanswer dismissal of a CPLR article 78 petition brought on by order to show cause is not an appeal from an ex parte order; therefore, the appeal is taken as of right.
The court erred in dismissing the petition sua sponte prior to service of a responsive pleading. Failure to exhaust administrative remedies is not an element of an article 78 claim for relief, but an affirmative defense which must be raised by respondent either in an answer or by preanswer motion or else be deemed waived (Matter of Consolidated Edison Co. v Public Serv. Commn., 98 AD2d 377, 381, mod 63 NY2d 424; Matter of Mallard v Dalsheim, 97 AD2d 545, 546-547). The judgment dismissing the petition should be reversed, the petition reinstated and respondent directed to move or answer. (Appeal from judgment of Supreme Court, Cayuga County, Contiguglia, J.—art 78.) Present—Denman, J. P., Boomer, Green, O’Donnell and Schnepp, JJ.