开发者

WCF Service under loadbalancer problem

In loadbalancer (bigip/f5) environment WCF 开发者_高级运维services are not working after the website is set to run under asp.net 4.0. The Javascript proxy requests are going as http instead of https under asp.net 4 which is causing “Access denied” errors in JS.

the same working with no issues on previous version of asp.net. Any idea??


This is a .NET4 regression that has been reported to Microsoft on Connect (please go vote it up), but has no fix from Microsoft as of yet. For now we wrote some F5 rules that rewrites the protocol in the content on the way back out. Sucks, but prevents having to change anything at the app level (like writing a custom HttpModule).

First we check if it's a we have to even process the request, if so we flag and remove the Accept-Encoding header from the client because otherwise we wouldn't be able to mess with the content if it got GZipped on the way back:

when HTTP_REQUEST
{
   set normalizedPath [string toupper [HTTP::path]]

   if {$normalizedPath ends_with ".SVC/JS" || $normalizedPath ends_with ".SVC/JSDEBUG"}
   {
       set needToFixSvcReference 1

       if {[HTTP::header exists "Accept-Encoding"]}
       {
           HTTP::header remove "Accept-Encoding"
       }
   }
   else
   {
      set needToFixSvcReference 0
   }
}

Then for the response processing we check if we were supposed to mess with the response and if so we collect the content:

when HTTP_RESPONSE {
   if($needToFixSvcReference equals 1)
   {
       # grab the response
       if { [HTTP::header exists "Content-Length"] }
       {
          set content_length [HTTP::header "Content-Length"]
       }
       else
       {
          set content_length 20000
       }


       if { $content_length > 0 }
       {
            HTTP::collect $content_length
       }
   }
}

Then we again check if we're supposed to do anything with this response and replace any set_path("http with set_path("https.

when HTTP_RESPONSE_DATA {
    if { $needToFixSvcReference equals 1 } 
    {
        HTTP::payload replace 0 [HTTP::payload length] [string map {set_path("http set_path("https}[HTTP::payload]]
        HTTP::release
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜