简体   繁体   中英

Force HTTPS redirection on Azure web service (API)

I'm setting up an API on Azure as a web service. I want it to force HTTPS for all the HTTP verbs (GET, POST, DELETE, etc.)

The blog post here tells to add a rule in the web.config file (towards the bottom of the blog post, it's quite lengthy.) Here is the rule:

<!-- BEGIN rule TAG FOR HTTPS REDIRECT -->
    <rule name="Force HTTPS" enabled="true">
        <match url="(.*)" ignoreCase="false" />
        <conditions>
            <add input="{HTTPS}" pattern="off" />
        </conditions>
        <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
    </rule>
<!-- END rule TAG FOR HTTPS REDIRECT -->

I tried doing that and it works okay for GET requests. However, when I try for POST requests, the web service now somehow interprets that request as GET request.

Any pointers on how to set up the rule for remaining verbs as well?

GETs are enabled by default, you have to enable the other http verbs. Shortest Version is the "Enable HTTP Verbs" section in the azure cheat sheet: http://microsoftazurewebsitescheatsheet.info

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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