Is it right to let my ex boyfriend to visit me while my husband is not aware of it? .then i later told him
It is not allowed for the wife to let even a mahram, let alone a non-mahram, to enter her husband's house without his permission. This is mentioned in many ahadith:
Abu Hurairah (May Allah be pleased with him) reported: Messenger of Allah (ﷺ) said, "It is not lawful for a woman to observe (voluntary) fasting without the permission of her husband when he is at home; and she should not allow anyone to enter his house without his permission.".
It was narrated that: Sulaiman bin Amr bin Ahwas said: “My father told me that he was present at the Farewell Pilgrimage with the Messenger of Allah. He praised and glorified Allah, and reminded and exhorted (the people). Then he said: 'I enjoin good treatment of women, for they are prisoners with you, and you have no right to treat them otherwise, unless they commit clear indecency. If they do that, then forsake them in their beds and hit them, but without causing injury or leaving a mark. If they obey you, then do not seek means of annoyance against them. You have rights over your women and your women have rights over you. Your rights over your women are that they are not to allow anyone whom you dislike to tread on your bedding (furniture), nor allow anyone whom you dislike to enter your houses. And their right over you are that you should treat them kindly with regard to their clothing and food.' ”
And Allah knows Best