On September 22, 1916, the trial court entered a decree of foreclosure covering the land involved in this controversy. It contained an order that the purchaser at the foreclosure sale be let into possession, and that any of the parties to the action, or any person coming into possession under them, should deliver possession to such purchaser, on production of the sheriff's deed. Respondent F. D. Williams, receiver, was the plaintiff, and appellants were-the defendants in said foreclosure action; appellants made no appearance, and judgment was by default. On October 28, 1916, the land was sold to respondent F. D. Williams, receiver, and the sheriff’s certificate of sale issued to him. Respondent Nixon purchased the certificate of sale and, upon the expiration of the time-for redemption, secured a sheriff’s deed to the land on July 9, 1918. On August 14, 1920, he filed an affidavit for a writ of assistance. No notice was given to appellants, but the clerk of the court issued the writ of assistance ex parte. On August 16, 1921, appellants made a motion to quash the writ of -assistance supported by the affidavit of appellant E. H. Sherman. Among other grounds of said motion, appellants stated that the writ of assistance was issued by the clerk of the court without an order of the court, that it was issued ex pajrte without notice, and to one who was not a party to the action. Thereafter respondent Nixon made a motion to strike said affidavit. The trial court sustained his motion to strike and denied appellants’ motion to quash the writ. From these orders this appeal is taken.
Among other specifications of error, appellants contend that the writ of assistance was improperly issued for the reasons just above stated. The power of the court to issue a writ of assistance in this state does not arise from any statute, but from the practice which obtained at common law. This power has always been exercised by courts of equity to place a purchaser of mortgaged premises in possession, after a decree of foreclosure, the expiration of the period of redemption, and the execution and delivery of the *173sheriff’s deed, where the possession is withheld by any party bound by the decree. (Harding v. Harker, 17 Ida. 341, 134 Am. St. 259, 105 Pac. 788; 27 Cyc. 1740 (C).) The exercise of the power to grant the writ rests in the sound discretion of the court. (19 R. C. L., sec. 455, p. 638; City of San Jose v. Fulton, 45 Cal. 316.) We have been cited to no authorities holding that it is a ministerial act which can be performed by the clerk of the court. The writ, having been issued by the clerk on his own authority, is void. Respondents’ counsel have cited us to some authorities holding that, if the decree of foreclosure contains an order for the surren‘der of the property to the purchaser, no further order to that effect is necessary before the writ issues. Even these authorities do not go to the length of holding that the writ can be issued by the clerk. The authorities are in conflict as to whether the writ can be issued ex parte without notice to the party in possession. Some authorities hold that it can be so issued where the decree contains a provision for surrender of possession, and the one in possession was a party to the foreclosure proceeding. Other authorities hold that it is better practice to give notice to the party in possession. Other authorities hold that the giving of notice is necessary. (San Jose v. Fulton, supra; Hooper v. Yonge, 69 Ala. 484; Knight v. Houghtalling, 94 N. C. 408; Fackler v. Worth, 13 N. J. Eq. 395.) It must be remembered that the issuance of the writ of assistance does not immediately follow the decree of foreclosure, but the period of redemption intervenes. The reason given for requiring notice is that the rights of the parties may have changed by reason of agreement, or circumstances, arising between the rendition of the judgment, and the application for the writ of assistance. We conclude that the better and more orderly practice, and the one more likely to protect the rights and interests of all concerned, is to require the giving of notice of application for the issuance of the writ to the party in possession. It was error to deny the motion to quash the writ. Appellant’s contention that respondent Nixon was not entitled to a writ of assistance because he was not a party to the foreclosure suit is dis*174posed of by Noble v. Harris, 33 Ida. 401, 195 Pac. 543, which decides that the holder of the sheriff’s deed is the real party in interest, and the proper person to apply for a writ of assistance.
Respondent contends that the motion to vacate the writ of assistance was a collateral attack, and therefore forbidden. In so far as the grounds of attack above mentioned are concerned, it is not collateral. A judgment or order can always be attacked by motion in the main action on the ground that it appears to be void on its face. The fact that it was issued ex parte can also be raised by motion to quash. (City of San Jose v. Fulton, supra.) As to whether certain other grounds set forth in the motion would constitute a collateral attack on the judgment, we express no opinion.
The affidavit of appellant E. H. Sherman set forth, among other facts, that the writ of assistance was issued by the clerk without notice to appellants. These facts are material and proper to be considered on the motion. Therefore the order striking the affidavit was error, regardless of whether or not other matter set forth in it could be considered on the motion.
In view of the conclusion we have reached upon the points above mentioned, it is unnecessary for us to pass upon other specifications of error and points set forth in the appellants’ brief and we refrain from doing so.
For the reasons given, the orders striking the affidavit and denying the motion to vacate the writ of assistance are reversed. Costs awarded to appellants.
Rice, C. J., and Dunn, J., concur.