Miracast or wireless display or wireless projection might fail when connecting to miracast device or wireless display device such as tv and projector.
When I went through for the tips in resolving the issue, most of them are about creating new firewall rules or disabling Windows Defender Firewall. However, adding new rules for %systemroot%\system32\WUDFHost.exe sometimes not fix the issue because the rules already there by default (local rule).
In some cases, miracast works in projecting from PC to TV but not when PC is joining to domain.
Disabling Windows Defender Firewall would solved the issue but it exposed PC to unwanted inbound and outbound connections.
On above 2 scenarios, the tips failed to fix miracast because of "Apply local firewall rules" setting as No. That mean, any local firewall rules will not applied. You can find this setting in Windows Defender Firewall with Advanced Security > Windows Defender Firewall properties and in public profile.
Bare in mind. Miracast connection is public and firewall rules for %systemroot%\system32\WUDFHost.exe already set as default (local) which I found it useless. Therefore, "Apply local firewall rules" setting must be set to Yes and add another rule for %systemroot%\system32\WUDFHost.exe for both inbound and outbound. So, you can have Miracast connection without disabling Windows Defender Firewall.
In other scenario, especially for big companies and enterprises that follow GPO security recommendation according to Microsoft, "Apply local firewall rules" will set to No. There is no way for IT to change it to Yes.
To fix micacast for this situation, create GPO in domain controller and add rule for %systemroot%\system32\WUDFHost.exe for both inbound and outbound connection. It is because rules for public profile only applied when rules are coming from GPO and not local.