asp.net mvc - IIS 7.5 URL Rewrite - Redirect from http to https for account controller but from https to http for everything else -


i've found bits , pieces of need make work, haven't been able bring workable solution.

i working on intranet site, , want secure *just logon , logoff actions on account controller https. have certificate installed correctly, , can redirect traffic these controller actions https using urlrewrite rule:

<rule name="redirect https" stopprocessing="true">     <match url="^account/logon$|^account/logoff$" />         <conditions>             <add input="{https}" pattern="^off$" />         </conditions>     <action type="redirect" url="https://{http_host}/{r:0}" redirecttype="permanent" /> </rule> 

now, however, want redirect *all of rest of site's requests (other traffic 2 actions) http. i'm not interested in debating merits of approach, have consider valid reasons wanting redirect out of https http.

i've tried writing code in actions achieve this, having major issues this. don't know if because i'm working 2 load-balanced servers or what, try gives me "too many redirects" error message.

so, 2 questions:

  1. is better use urlrewrite rule redirect out of https or controller actions?
  2. does have working code example or can @ least me started down right path?

any appreciated!

better late never. might or else.

<rule name="redirect http">         <match url="securedir/(.*)" negate="true" />         <conditions>           <add input="{https}" pattern="^on$" />         </conditions>         <action type="redirect" url="http://{http_host}{request_uri}" />       </rule>        <rule name="redirect https" stopprocessing="true">         <match url="securedir/(.*)" />         <conditions>           <add input="{https}" pattern="^off$" />         </conditions>         <action type="redirect" url="https://{http_host}{request_uri}" />       </rule> 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -