Day, Oh. J.
From the allegations of the answer it appears that Barrett became the purchaser of the mortgaged property, by a quit-claim deed filed for record 'March 19, 1873. On the 17th of February, 1871, the mortgagee procured a judgment of foreclosure in an action to which Barrett was not a party. On the 25th day of July, 1871, the property was sold under the foreclosure, and the defendant became the purchaser. As the decree of foreciostarwSifrehüered alter me uoae of 1873 took effect, the sale must have been conducted under the provisions of the Code, without appraisement and subject to redemption. Babcock v. Gurney, 12 Iowa, 154; Fonda v. Clark, 13 Id., 300. Section 3102 of the Code provides that: “The defendant may redeem real property at any time within one year from the day of sale as herein provided, and will in the mean time be entitled to the possession of the property.” Section 3321 of the Code provides: “When a mortgage or deed of trust is foreclosed by equitable proceedings, the court shall render judgment for the entire amount found to be due, and must direct the mortgaged property, or so much thereof as is necessary, to be sold to satisfy the same with interest and costs. A special execution shall issue accordingly, and the sale thereunder shall be subject to redemption, as in cases of sale under general execution.” Under the provisions of these sections we have no doubt that the purchaser at a foreclosure sale is not entitled to the possession of the premises until after the expiration of the year for redemption. A much more difficult -question arises as to the right of defendant to posses*569sion after the expiration of the year for redemption, as against Barrett, the purchaser from the mortgagor, who was not made a party to the foreclosure proceeding. Our statute provides that: “In the absence of stipulations to the contrary the mortgagor of real property retains the legal title and right of possession thereto.” Code of 1873, section 1938 (Revision 2217). One of the logical consequences flowing from vesting the legal title and right of possession in the mortgagor is that the mortgaged property in his hands possesses all the incidents? of real estate. The mortgagor - m%y lease, sell, antT m evecvl respect deal with the mortgaged property as owner, the only reSLhclllUll lieihv IllkL every person taking under him — taires subiecTTO all tlitTTilfh1^~olNhe~ mortgagee. Upon the death of the mortgagorThe mortgaged estate passes to his heirs, and his widow becomes entitled to dower therein. The vendee of\ the mortgagor steps into the mortgagor’s place, and becomesj entitled to his possession. He holds the property as the mortgagor held it, subject to the same burdens and entitled to the same privileges. So completely does a sale of the mortgaged property divest the mortgagor’s interest, and vest it in his vendee, that it has been held that a mortgagor who has sold all his interest in the property, subject to the mortgage, is not a necessary party to a foreclosure suit. Murray v. Catlett, 4 G. Greene, 108; Johnson v. Monell, 13 Iowa, 300; Semple v. Lee, Id., 304.
The purchaser from the mortgagor being thus subrogated to all the rights of tbe mortgagor, it follows that, until foreclosure and sale, and the expiration of the year for redemption, he has tflg-nijaht-ln Iho m.MseiDJlOil Of thé faortyywl propagó and is^ntitled to the rents and profits. The plaintiff purchased the mortgagéd preffuses and filed his deed for record, before the foreclosure proceedings were had under which defendant claims he acquired a right to the possession. This purchase vested in plaintiff the legal title, and the right to possession; subject to the lien of the mortgage. Certainly, up to the time of the foreclosure proceeding, plaintiff was entitled to the possession of the property. To the foreclosure proceeding the plaintiff was not a party; he is, therefore, in no way affected *570by it. Heimstreet v. Winnie, 10 Iowa, 430, and cases cited; Chase v. Abbott, 20 Id., 154; Frisch v. Cramer, 16 Ohio, 137; Haffley v. Maier, 13 Cal., 13; Boggs v. Hargrave, 16 Id., 559; Carpenter v. Williamson, 25 Id., 151; Watson v. Spence, 20 Wend., 260.
In the last ease Mr. Chief Justice Field, announcing the opinion of the court, said: “'To give validity to such decree, the owner must be before the court when it is rendered. No rights which he possesses can otherwise be affected, and any direction for their sale would be unavailing for any purpose. A mortgagor, when he has not disposed of his interest, is a necessary party to a suit for foreclosure and sale under our law, even though no personal claim be asserted against him. The fact that a mortgage is executed upon the premises does not, of itself, authorize proceedings for their sale without making him a party. He has a right to be heard before his estate can be subjected to sale to satisfy any alleged lien, -without reference to any personal claim against himself. If he has parted with the estate his grantee stands in his shoes, and possesses the same right to contest the lien and to object to the sale. The object of the sale is to subject such estate as the mortgagor held at the time to the satisfaction of the lien which he created; and if that estate has been disposed of a decree directing its sale without the presence of its owner would be a mere arbitrary act, condemning without hearing one man’s property to pay another man’s debt. It is only when the owner of the estate has had his day in court, that a valid decree can pass for its sale. It is only under a decree of this nature that a purchaser can acquire any title.”
In Haffley v. Maier, 13 Cal., 13, it was held that the vendee of the mortgagor cannot be ousted from possession by a purchaser under the decree of foreclosure, unless such vendee was made a party to the foreclosure proceedings. But we are not now called upon to determine what would, at law, have been the rights of Barrett, if the purchaser at the foreclosure sale had not instituted any proceeding to foreclose his interests. After the sale, on the second day of February, 1875, the defendant commenced his action against Barrett, for the foreclosure *571of tbe mortgage, claiming $615.00 and interest at ten per cent, and costs, asking a decree that Barrett redeem the said premises from the mortgage and sale, or that he be barred and foreclosed of the right to redeem.
1. mortgage: ^mortgagor• rems. The rights of the parties were thus drawn within the jurisdiction of a court of equity, and they are to be determined by equitable principles. In equity the right of a purchaser from the mortgagor who is not made a party to the foreclosure is to redeem from the mortgage. Porter v. Kilgore, 32 Iowa, 380; Douglass v. Bishop, 27 Id., 214; Bates v. Ruddlick, 2 Id., 423. The party bringing his action to redeem is entitled to rents and profits, and, under some circumstances, he is chargeable with valuable and lasting improvements. Montgomery v. Chadwick, 7 Iowa, 114 (134). In the action to redeem the court should consider both the right to rents and the liability to pay for improvements, as these questions must be determined in' order to ascertain the amount which should be paid to redeem. If the court had considered the respective claims of the parties in this case, and had determined that $700 was the proper amount that plaintiff should pay in order to effect a redemption from the mortgage, the presumption would be that the court arrived at this sum after allowing- plaintiff all proper sums as rent, and charging him with all proper amounts for improvements, or that under the case as presented the plaintiff was not entitled to rents, and was not chargeable with improvements. In either case the decree would be a finality between the parties, reviewable only on appeal. The amounts due for rent are just as intimately connected with, and entelas closely into the determination of the amount necessary to redeem, as payments upon a debt are connected with and enter into the question of the amount due thereon. A party who fails to plead payment, and allows judgment to be recovered for too large a sum, cannot be relieved unless he was prevented by accident, surprise, mistake or fraud of the opposite party from making his defense. Doyle v. Reilly, 18 Iowa, 108 (113), and cases cited. In this case, however, the court did not determine the amount which Barrett should pay to redeem. *572He appeared to the action, filed his answer, admitted the claim made by the petition, asked that he be permitted to redeem, and offered for that purpose the sum of $700, paying it into court for the purpose of redemption. The defendant accepted the offer, and a decree was entered permitting Barrett to redeem from the mortgage and sale, and establishing his title freed from the incumbrance. It was the duty of Barrett in making this offer to take into consideration his right to rents, and his liability for improvements, and to offer such sum as he was willing to. pay, after considering both these items, to the end that the rights of the parties might be finally and fully adjudicated, and an end -put to litigation respecting them. The presumption is that he took these matters all into account. If he did not, he must show that he omitted to do so through accident, surprise, mistake or fraud of the opposite party, before he can recover the rents in a separate action.
We think ■ the demurrer to the answer should have been overruled.
Reversed.