I'm trying to deploy an ASP.NET MVC web application, which uses individual user accounts, to an AWS server, which is using an elastic load balancer (ELB). I've deployed the site to IIS on the AWS app server, connected it to my AWS SQL server, and it works as expected on the server (and indeed when I run it in Visual Studio or deploy to an internal server).
The problem comes when accessing it remotely, which of course goes via the ELB.
- If I try and access https://www.example.com/ it doesn't work - it will redirect me to http://www.example.com/Account/Login?ReturnUrl=%2F, which hangs and I then get a 408 error.
- If I try and access, say, https://www.example.com/Dashboard/Index it doesn't work - it will redirect me to http://www.example.com/Account/Login?ReturnUrl=%2FDashboard%2FIndex, which hands and I then get a 408 error.
- If I try and access https://www.example.com/Account/Login directly, it works fine. I can then log in and all pages in my site work as expected. If I log out though, I get redirected to http://www.example.com/Account/Login?ReturnUrl=%2F, which hands and I then get a 408 error.
So basically, if I'm logged in, it's fine. If I'm not logged in, the login page is fine but nothing else is. My thinking, along with a colleague from our internal team who works with AWS (he isn't able to help me btw, I've asked!) is that when I get redirected to the login page, it's a HTTP request and not HTTPS, and that's the cause of the issue, but no matter what I've tried I can't get it to redirect with HTTPS. I've tried:
- adding rules in my web.config file to pick up forwarded requested and redirect them to HTTPS - which doesn't seem to have made any noticeable difference
- various different attributes added to either my FilterConfig or the Login action
- adding rules directly in IIS using URL Rewrite
Obviously my workaround is to get everyone to go to the login page and start there rather than just the root URL, but I'd really like to get this sorted as if redirecting doesn't work here, I can see it not working elsewhere and potentially causing issues.
Update as requested: I don't actually have any control over my ELB as that's done by a different team, but my understanding from speaking to the team is that it accepts traffic as HTTPS and then passes it on to the server as HTTP.
web.config
file, what is theloginUrl
value in theforms
element? – Matt Houserforms
element in myweb.config
- I have<authentication mode="None" />
, which I believe was from the original ASP.NET MVC template – alfredbulbasaurDashboardController
to require authorization, and (b) what page to redirect to to get the user to sign-in. – Matt Houser