2

Just to preface this: I know that this is a horrible idea, but just trust me here. If I was in any other position I would avoid doing this.

I have an application built in Visual Studio that uses IIS on HTTPS port 44300. I am replacing some HTTPS API requests with others that use HTTP. Chrome prevents these requests with mixed content errors. I have looked at other questions that mention the same thing and all come up with hacky answers that should never be used in production.

Since there is no chance that I can get the API to switch to HTTPS, I am looking to modify my app to run on HTTP.

My attempt at doing this is modifying the project's properties. (Project -> Properties -> Web -> Servers). Editing the project

You can see that I have the project URL set to use HTTPS

When I change that url to be http://localhost:44300 the application starts me at https://localhost/ even though that's not the config, and tells me that localhost can't be reached. No big deal, I manually change the URL to be http://localhost:44300 and it sends me back to https://localhost/. When I leave out the port and just manually enter http://localhost I get a 404 page.

I have also tried setting the port to 80 in the Project properties page. I just get automatically redirected to https://localhost when I delete the S.

The app is built using ASP.NET.

Is there some obvious issue that I'm not seeing with IIS and the port? Or is this an issue with the way that my app is built? In which case, this is a bad question.

Tyler Miller
  • 1,232
  • 10
  • 18
  • Do you also have the normal IIS installed? It might be redirecting to https://localhost – Mitta Aug 16 '17 at 22:30
  • Following [these steps](https://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx) _in reverse_ may help – stuartd Aug 16 '17 at 22:31
  • @Mitta I believe it came installed with my computer. I can try reinstalling it. – Tyler Miller Aug 16 '17 at 22:35
  • @fstylermiller you can check this in the "Windows features" panel. There must be a "Internet Information Services" node. See if this is checked, if it is, IIS is installed. In that case see if this IIS might be doing the redirect as mentioned before. – Mitta Aug 16 '17 at 22:38
  • @Mitta funny enough, it is there, but not checked. – Tyler Miller Aug 16 '17 at 22:46
  • Since you are using IISExpress, did you check applicationhost.config file under `.vs\Config` folder? Normally this folder is hidden folder and is located where solution file resides. – Pankaj Kapare Aug 16 '17 at 23:33
  • @PankajKapare I did check that file, no mention of http or https :( – Tyler Miller Aug 17 '17 at 16:07

2 Answers2

4

Check if your Web.config includes the following lines

<httpRedirect enabled="true" destination="https://localhost" /> 

or

UrlRewrite configuration

<action type="Redirect" url="http://example.com/{R:1}" />

It might also have to do with HTST and Chrome in case you use Chrome. See this answer

Google Chrome redirecting localhost to https

Mitta
  • 443
  • 4
  • 12
  • Web.config does not have either of those, and that answer did not solve the problem. Thank you for the effort, though. – Tyler Miller Aug 16 '17 at 23:18
0

It ended up being an issue with the way that my app was configured.

This line was the culprit:

filters.Add(new RequireHttpsAttribute());
Tyler Miller
  • 1,232
  • 10
  • 18