Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the Url of the website we are calling from

I am trying to get the path of the current website and I am doing this to get the url.

Uri uri = HttpContext.Current.Request.Url;
string callbackUrl  = uri.Scheme + "://" + uri.Host + (uri.IsDefaultPort ? "" : ":" + uri.Port) + "/Work";

It works fine on development server, but does not work in production which is a https site.

uri.Scheme gives me http. What am I doing wrong here. Is there a way that uri.Scheme returns https instead of http when this code is called from a https site.

Thanks

like image 706
gurrawar Avatar asked Dec 04 '25 15:12

gurrawar


1 Answers

IIS does some filtering that affects Request.Url for https requests. Ended up doing some Googling and it seems like there are a few limitations. You might have to come up with a custom solution based on this blog post.

like image 147
Nadir Muzaffar Avatar answered Dec 06 '25 18:12

Nadir Muzaffar