Reputation: 1203
I want to check whether the incoming url having http or https in c#? Is there any default method to find the url scheme(http/https)?
Upvotes: 2
Views: 5886
Reputation: 4572
You could use Uri.Scheme to check and see if it is https.
You could also just use Request.IsSecureConnection
Upvotes: 5
Reputation: 12904
var currentUrl = System.Web.HttpContext.Current.Request.Url;
if (!currentUrl.Scheme.Equals(Uri.UriSchemeHttps,
StringComparison.CurrentCultureIgnoreCase))
For more information : Uri.UriSchemeHttps Field
Upvotes: 2