Lightly grease a 13x9-inch baking dish and set aside.
Cook the spaghetti according to package directions, till just al dente. Drain well, and allow to cool slightly (it should be warm, but not hot - see note).
Place the warm spaghetti in a large bowl and add the beaten egg and Parmesan cheese. Mix well, ensuring the spaghetti is evenly coated with egg and cheese. Transfer to the prepared baking dish, creating an even layer of spaghetti on the bottom and working some up the sides slightly.
In a large skillet, brown the sausage over medium-high heat. Cook for 5-7 minutes or until the meat crumbles and is no longer pink. Remove the sausage to a paper towel-lined plate and set aside.
Drain excess grease from the skillet and add the pepperoni. Cook over medium heat, stirring occasionally, until slightly crisp.
To assemble the casserole, top the spaghetti crust with the sausage, then pour the pasta sauce over the sausage. Next, arrange half of the pepperoni slices over pasta sauce. Sprinkle evenly with the cheeses and top with the remaining pepperoni slices.
Bake at 350° F for 30-40 minutes or until cheese is melted and begins to brown.
Allow to cool for 5-10 minutes, then slice and serve.