简体   繁体   English

如何使用带有https而不是localhost的域名在IIS中调试网站

[英]How to use Domain name with https instead of localhost for debugging website in IIS

I am implementing Single Sign On(using OKTA) on one of our MVC based website where the OKTA takes a Response URL to throw its response back to my code once the user has entered his credentials on OKTA login page 我正在基于MVC的网站之一上实现单点登录(使用OKTA),一旦用户在OKTA登录页面上输入了凭据,OKTA就会使用Response URL将响应返回给我的代码

OKTA takes an HTTPS based response URL to throw its response. OKTA使用基于HTTPS的响应URL来抛出其响应。

Things I have done: 我所做的事情:

1) I have specified a dummy Hostname to my machine using etc/hosts file like: 1)我已使用etc / hosts文件为计算机指定了虚拟主机名,例如:

127.0.0.1 www.abc.com 127.0.0.1 www.abc.com

2) Enabled https:// on www.abc.com on my local machine 2)在我的本地计算机上的www.abc.com上启用https://

3) Specified a route {{controller}}/{{Action}} to receive the response in my code. 3)指定路由{{controller}} / {{Action}}以接收我的代码中的响应。

4) I have tried specifying Bindings to my local applicationConf file: 4)我尝试指定到本地applicationConf文件的绑定:

             <bindings>
                <binding protocol="http" bindingInformation="*:58565:localhost" />
                  <binding protocol="https" bindingInformation="*:443:www.abc.com" />
            </bindings>



My VS project configuration looks like this: 我的VS项目配置如下所示:

在此处输入图片说明


Is it possible to receive the response on the local MVC route (hit the breakpoint) when the URL (where OKTA throws response) is like https:// www.abc.com/Home/Auth 当URL(OKTA引发响应的地方)如https://www.abc.com/Home/Auth时,是否可以在本地MVC路由上接收响应(命中断点)

Problem is when I write localhost:58565/Home/Index or http:// www.abc.com/Home/Index with VS debugging on, it hits the breakpoint but when I type https:// www.abc.com/Home/Index (with https) it does not hit the breakpoint in Visual Studio. 问题是当我在VS调试打开的情况下编写localhost:58565 / Home / Indexhttp:// www.abc.com/Home/Index时,它遇到了断点,但是当我键入https:// www.abc.com/Home时/ Index (带有https),不会在Visual Studio中达到断点。 With https it says 404 Not found. 使用https表示404未找到。

Am I missing something? 我想念什么吗?

Thanks 谢谢

I got the issue fixed. 我已解决问题。 Posting the solution so that it may be helpful for others. 发布解决方案,以便对他人有所帮助。

Steps I followed: 我遵循的步骤:

1) Created a Self signed certificate with Powershell(make sure you run Powershell command line with Admin Privileges) 1)使用Powershell创建一个自签名证书(确保您使用Admin Privileges运行Powershell命令行)

New-SelfSignedCertificate -DnsName www.mydomain.com -CertStoreLocation cert:\LocalMachine\My

2) Have correct bindings in my ApplicationConf.host file(this file is now at Project level now since VS 2015 rather than at IIS level) like the one below: 2)在我的ApplicationConf.host文件中具有正确的绑定(自VS 2015开始,此文件现在处于Project级别,而不是IIS级别),如下所示:

        <bindings>
                <binding protocol="http" bindingInformation="*:58565:localhost" />
                <binding protocol="https" bindingInformation="*:44311:localhost" />
       </bindings>

You can add more bindings if using Hostname instead of Localhost. 如果使用主机名而不是Localhost,则可以添加更多绑定。 Make sure ports are different for each binding. 确保每个绑定的端口都不同。 Also, Https ports should start from 443--ending at 44399. 另外,Https端口应从443开始-结束于44399。

3) Remove the existing https binding from IIS Default Website and add it back with the certificate created in Step 1 and correct hostname used in Step 1. 3)从IIS默认网站中删除现有的https绑定,然后将其添加回步骤1中创建的证书并更正步骤1中使用的主机名。

Now you should be able to run and debug your code on local machine with self signed SSL. 现在,您应该可以使用自签名SSL在本地计算机上运行和调试代码了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM