This site can’t provide a secure connection

后端 未结 4 1778
被撕碎了的回忆
被撕碎了的回忆 2021-02-12 10:51

When I added the URL rewrite code in web.config and then publish it into azure. it will automatically redirects to https even I am trying to access website with http.

         


        
4条回答
  •  逝去的感伤
    2021-02-12 11:30

    What I do personally is put that rewrite configuration into Web.Release.config precisely because it is a bit fiddly to get it working locally.

    The problem is that IIS Express will expose HTTP and HTTPS on different ports, so if you redirect from http://localhost:1234 to https://localhost:1234, it simply won't work, because IIS Express is exposing HTTPS on something like https://localhost:44300.

    You can enable SSL/TLS on IIS Express (and you should), but I would leave the rewrite rule only for Release mode.

    Here is an example Web.Release.config file:

    
    
      
        
      
      
        
          
            
            
              
              
                
              
              
            
          
          
            
            
            
              
              
                
              
              
            
          
        
      
    
    

    Note that I also add HSTS here. It inserts the element into Web.config in Release mode. The element already exists in Web.config, otherwise I would be inserting that.

提交回复
热议问题