Most of the time, we want to use Asp.net's membership to quickly handle problems such as role verification. In addition, the customer service can share a set of accounts with the BS system.
The proxy class in WebService inherits from webclientprotocol, And the webclientprotocol contains two methods.
Protected virtual webrequest getwebrequest (URI );
Protected virtual webresponse getwebresponse (webrequest request );
It should be clear that calling WebService is essentially an http post request. Unlike ordinary HTML, the content of the WebService request and the content returned by the service are not HTML, but XML (SOAP protocol ). Let's look at these two methods again, so the proxy will certainly call these two methods when calling the service. Therefore, we only need to rewrite the two methods as appropriate.
Private Static string currentcookie = string. Empty; protected override webrequest getwebrequest (URI) {webrequest request = base. getwebrequest (URI); If (! String. isnullorempty (currentcookie) {request. headers [httprequestheader. cookie] = currentcookie;} return request;} protected override webresponse getwebresponse (webrequest request) {webresponse response = base. getwebresponse (request); If (! String. isnullorempty (response. headers [httpresponseheader. setcookie]) currentcookie = response. headers [httpresponseheader. setcookie]; return response ;}
We directly intercept the cookie from the HTTP request header. before sending the cookie, We append the cookie to the request header.
Server, Web. config needs to be configured,
<System. webserver> <modules runallmanagedmodulesforallrequests ="True"/> </System. webserver>
Enable all module channels to verify permissions.