2010-01-18 77 views

回答

4

使用WebOperationContext類(在System.ServiceModel.Web中) - 它使您可以訪問HttpContext請求的等效項。

但是,除非啓用Asp.Net託管,否則您不一定會獲得相同的信息,因爲在這種情況下,IIS僅用作服務的激活方法,而不是主機。而將AspNetCompatibilityRequirements設置爲Required或Allowed時,服務實際上託管在IIS內的Asp.Net中。