main-qimg-ede82c522fb1530c2f8fe449ee9c8b46

This will depend on the type of visa you are currently allowed to remain in the UK. If you are on a visitor visa this will not be permitted to switch. If you entered on a fiancé visa, you will be allowed to get married from inside the UK and apply for a Spouse visa to continue to remain in the UK. If you are on a Tier 4 Student visa, this will also allow you to switch to a UK Spouse visa subject to meeting the requirements of the Immigration rules.

Original Source: https://www.quora.com/Can-you-apply-for-a-UK-spouse-visa-while-in-the-UK/answer/My-Legal-Services-1