Request.UrlReferrer.AbsoluteUri losing HTTPS navigation

TheMatrix

Member
Joined
Feb 15, 2008
Messages
14
Programming Experience
5-10
Hi All,

I am facing a weird problem with HTTPS and Request.Url.AbsoluteUri in my
ASP.NET application. Here is the scenario -
1. I have a page call Authentication.aspx using this URL https://NHWB032/ClientAccount/EN/Authentication.aspx
On the page i have a menu that enables you to navigate to the same page but in a different language (French).

When clicking the language link i navigate to http://NHWB032/ClientAccount/FR/Authentication.aspx

and i am using Request.Url.AbsoluteUri to know on which page i am since i have more than 1 page containing the language menu.

If you notice between the 2 links Request.Url.AbsoluteUri got change from HTTPS to HTTP

PROBLEM - the result has HTTP instead of HTTPS!!!!!

Has anybody faced a similar problem or has some insight into what could be
going wrong and could anybody give me the best resolution to this problem i.e.:Change the code, Change settings on the server and IIS.etc.?

Thanks for your help!
 
How did you create the new url? Uri.AbsoluteUri doesn't loose the scheme.
 
Hi JohnH,

Thanks for the quick reply!

I do a little like this when creating the new URL in a button event and when i redirect, it loses the HTTPS:

I am on a Windows 2003 server and would like to know if i need to configure something in IIS in order to always get redirected to secure pages.

Private Sub Button_Language_Change_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Language_Change.Click
'Could be more than 1 page passing here
Dim redirectURL As String = Request.UrlReferrer.AbsoluteUri.Replace("/EN", "/FR")
Response.Redirect(redirectURL)
End Sub

I also found this on another thread reporting the same type of problem but i would like to know what would be the better approach to resolve this issue since this is the first time i notice this:

most likely the iis server is not running https itself, but the support has
been offloaded to a frontend bridge/router/proxy. the router uses https to
client (browser) but uses http to the iis box.


Thanks again
 
Https is configured in IIS.
UrlReferrer:
Gets information about the URL of the client's previous request that linked to the current URL
Was perhaps the previous page Http (which linked to current Https page) ?
 
Thanks again,

Yeah this could have been an issue but all my pages uses HTTPS. Could you please give me some guidance on what to look for in IIS i.e.: Virtual Dir properties, Default Web Sites properties.etc. in order to be well configure and not have that kind of problem with the server?

When i run this on my localhost no problem my url stays the same but on the 2003 server, it changes from HTTPS to HTTP and i use the same code
 
Thanks for the link,

Since we have another group here that takes care of configuring servers its hard for me to know if it was done properly and we always need to have the solution for them since they are incompetent :). Do you think by NOT configuring folders or Web Site to use SSL/HTTPS would create that kind of problem for the Request.Url.AbsoluteUri losing the HTTPS?

I know i could force thing in my code but i want to ensure that IIS has everything it needs. Is this the only thing to look for in IIS that would create that kind of problem or i could i look at something else?

Thanks again, i am a new member but know my .NET stuff (Except server configuration :confused:)so i am sure i could help you one of these days.
 
You know if IIS is configured correctly because you can't open a page by by http if it's configured for https and the other way around.
 
Thanks,

The thing that is weird is that i was using the same code and never encountered that problem before installing those Windows 2003 servers.

Since i am able to use HTTPS (When not using the UrlReferrer.AbsoluteUri for navigation) it should mean IIS is OK.

Probably i will need to force something into the code which i don't like since the UrlReferrer.AbsoluteUri should give me what i need.

Thanks for your help!
 
If UrlReferrer says previous page was Http, then previous page was Http, and not Https :)
 
If this was the case it would be perfect since i would stop scratching my head ;)

No i'me coming off an HTTPS link and by surprise with the UrlReferrer it gets change to HTTP.
 
Do you know another way we can get the previous URL dynamically without using the Request.Url.AbsoluteUri? I tried to google this but couldn't find strong issues.

Thanks
 
Request.Url is current page, Request.UrlReferrer is previous page.
 
And sorry,

Everytime i was talking about Request.UrlReferrer i meant Request.Url since i am on the current page and want to redirect to a page in French.

Sorry i don't have my code in front of me since i started this thread at home, monday will be a better day :)
 
Back
Top