How to check if the device is Desktop, Android or IOS in C# .Net Core Razor pages?

Explaination:

I am currently working on VS2022 and Net Core 9.0.

I want to be able to send SMS to the client by clicking on a button.

After the App checks the device type, it selects the right button.

My problem is that Android and IOS have different syntaxes.

Question:

How can i detect if the device is Desktop, Android or IOS? Is there a method to do this?

Code:

To work on Android:

<a href="sms:/* phone number here */?body=/* body text here */">Link</a>

To work on iOS:

<a href="sms:/* phone number here */&body=/* body text here */">Link</a>