Opinion by
Judge Barry,This appeal follows an order of the Court of Common Pleas of Philadelphia County which sustained preliminary objections filed by the City of Philadelphia (City) and the School District of Philadelphia (School District) and dismissed, with prejudice, the complaint filed by plaintiffs, appellants herein.1
On October 17, 1980, George Ziccardi, a student at Bok Vocational High School, a public school in Philadelphia, was attacked on the sidewalk immediately adjacent to the school by persons other than the defendant and then was shot by defendant, Clarence Everett, while on the steps leading into and from the school building. He suffered serious and permanent personal injuries and his parents sustained extensive financial expenses and losses due to his injuries. He filed a complaint against the City and School District to which they filed preliminary objections in the nature of a demurrer asserting, essentially, immunity from suit under Section 8542 of the Judicial Code, 42 Pa. C. S. §8542. On October 26, 1982, the trial court sustained the preliminary objections holding that the appellants’ claims did not fall within the eight exceptions to immunity set forth in this section.
*597Initially, appellants argne that the City’s and School District’s preliminary objections should not have been sustained because immunity from this suit under Section 8541 should properly have been raised as an affirmative defense in new matter and should not have been raised by means of preliminary objections.
In numerous cases we have addressed the question of whether the defense of immunity from suit raised by preliminary objection should be stricken. Swartz v. Masloff, 62 Pa. Commonwealth Ct. 522, 437 A.2d 472 (1981); Iudicello v. Department of Transportation, 34 Pa. Commonwealth Ct. 361, 383 A.2d 1294 (1978); Milk Marketing Board v. Sunnybrook Dairies, Inc., 32 Pa. Commonwealth Ct. 313, 379 A.2d 330 (1977); Harris v. Rundle, 27 Pa. Commonwealth Ct. 445, 366 A.2d 970 (1976); Schuman’s Village Square Drugs, Inc. v. Stern, 14 Pa. Commonweath Ct. 559, 322 A.2d 431 (1974). In each case we held that preliminary objections are a proper vehicle for raising immunity where the defense is apparent on the face of the pleading under attack. A review of the preliminary objections filed by the City and School District reveals that, in each case, the defense of immunity from suit is apparent on the face of the pleadings.2
Appellants next contend that they have stated a legal cause of action against both the City and the School District under Section 8542(b)(3) and (7).3 We disagree with this argument.
*598We .believe that .the iSohool District is immune from liability under ¡Section ,8542. On several occasions, we have held that tbe alleged negligent conduct ,on tbe part of a school district was not directly related to the care, custody or control of real property. Usher v. Upper St. Clair School Disrtict, 87 Pa. Commonwealth Ct. 461, 487 A.2d 1022 (1985); Vann v. Board of Education of the School District of Philadelphia, 76 Pa. Commonwealth Ct. 604, 464 A.2d 684 (1983); Close v. Voorhees, 67 Pa. Commonwealth Ct. 205, 446 A.2d 728 (1982); Robson v. Penn Hills School District, 63 Pa. Commonwealth Ct. 250, 437 A.2d 1273 (1981); Wimbish v. School District of Penn Hills, 59 Pa. Common*599wealth Ct. 620, 430 A.2d 710 (1981). .Section 8542(b) (3) has been construed to impose liability where there is an- 'allegation of a flaw in the real estate. Usher. Appellants have failed to allege a defect in the real estate and, therefore, absent this allegation, the School District cannot be held responsible under .Section 8542 (b)C3).4
For the .same reason, we do not believe the School District can be held liable under Section 8542(b)(7) since the appellants have failed to allege a physical defect in the .sidewalk. The -property is not a cause of injuries sustained.
We, furthermore, cannot assess liability against the City. Again, appellants have not alleged a .physical defect in the real .property necessary under Section 8542(b) (3) and, moreover, had such an .allegation been proved, the City would not be liable since this property was in possession of the School District and not it. The .sidewalk exception under Section 8542(b) (7) also does not apply because appellants did not allege any physical defect directly related to the sidewalk. Essentially, -they have alleged a general failure to prevent criminal misconduct. In Chapman v. City of Philadelphia, 290 Pa. Superior Ct. 281, 434 A.2d 753 (1981), the court held that, .absent a special relationship between -the City -of Philadelphia and an- individual, the City of Philadelphia could not be held liable at common law for an alleged failure to protect the public from criminal acts by third -parties. No special *600relationship existed here 'and thus the 'City cannot be held responsible.
Finally, Section 8542(a) (1) permits the imposition of liability against a local agency if damages would be recoverable under common law. We do not believe that appellants had a cause of action under the common law which would impose liability against either the School District or the.City.
For the reasons- set forth above, we affirm the order of the trial court.
Order
Now, September 12,1985, the order of the Court of Common Pleas of Philadelphia County, entered October 26, 1982, at No. 2530 of the August Term, 1982, is affirmed.
Appellants are George Ziccardi and his parents, John and Anna Ziccardi.
We further note that the proper manner to raise the challenge here asserted by appeUants would have been by a preliminary objection to the preliminary objection in the nature of a motion to strike for lack of conformity to law or rule of court. Swwtz.
Section 8542(b)(3) states as follows:
(3) Real Property. — The care, custody or control of real property in the possession of the local agency, except that the local agency shall not be liable for damages on account of any injury sustained by a person intentionally tres*598passing on real property in the possession of the local agency. As used in this paragraph, “real property” shall not include:
(i) trees, traffic signs, lights and other traffic controls, street lights and street lighting systems;
(ii) facilities of steam, sewer, water, gas and electric systems owned by the local agency and located within rights-of-way;
(iii) streets; or
(iv) sidewalks.
42 Pa. O. S. §8542(b) (3).
Section 8542(b)(7) provides:
(7) Sidewalks. — A dangerous condition of sidewalks within the rights-of-way of streets owned by the local agency, except that the claimant to recover must establish that the dangerous condition created a reasonably foreseeable risk of the kind of injury which was incurred and that the local agency had actual notice or could reasonably be charged with notice under the circumstances of the dangerous condition at a sufficient time prior to the event to have taken measures to protect against the dangerous condition. When a local agency is liable for damages under this paragraph by reason of its power and authority to require installation and repair of sidewalks under the care, custody and control of other persons, the local agency shall be secondarily liable only and such other persons shall be primarily liable.
42 Pa. C. S. §8542(b) (7).
In Vann, we held that Section 8542(b)(3) does not waive immunity merely because an unfortunate incident occurred on government-owned premises and thus construed the provision to impose liability only for negligence which makes government-owned property unsafe for the activities for which it is regularly used, intended to be used, or may be reasonably foreseen to be used. Under these conditions, liability cannot be imposed for the violent criminal act which occurred here.