How can I get the Current URL Protocol in DNN?

380 Views Asked by At

How can I get Https or Http in the backend code of a DNN module?

Currently, I have got this code, but I need the protocol (https:// or http://)

PortalSettings.Current.PortalAlias.HTTPAlias + PortalSettings.HomeDirectory + PortalSettings.LogoFile;
2

There are 2 best solutions below

0
VDWWD On BEST ANSWER

You can maybe use this to check if the current tab has https enabled (to check the request itself you can use Request.IsSecureConnection)

PortalSettings.ActiveTab.IsSecure

And/or

PortalSettings.SSLEnabled;
PortalSettings.SSLEnforced;
PortalSettings.SSLURL;
0
Mitchel Sellers On

If you want it for the current URL, you can use the regular .NET API's as well.

HttpContext.Current.Request.Url.Scheme

That will return http or https based on the current request URL. Its the fastest way that I'm aware of to do this.