Reputation: 35925
I want to set the cookie name to a different one in my WCF REST service.
I have set it on the Web.config:
<system.web>
<compilation debug="true" targetFramework="4.0" />
<sessionState timeout="99999" mode="InProc" cookieName="xxx"/>
</system.web>
But it does not work:
Request:
POST http://localhost/wcfrest/logon HTTP/1.1
User-Agent: Fiddler
Content-Type: application/json
Host: localhost
Content-Length: 40
{"Username":"sdf","Password":"sadfsdaf"}
Response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 19
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Set-Cookie: .ASPXAUTH=780210B[...]7627C58; expires=Thu, 22-Sep-2011 11:46:06 GMT; path=/
X-Powered-By: ASP.NET
Date: Wed, 21 Sep 2011 11:46:06 GMT
{"Successful":true}
Is there any other change I should do?
Thanks.
Upvotes: 0
Views: 947
Reputation: 49195
As such your request/response does not show session cookie. Response has authentication cookie named .ASPXAUTH
(note that session and authentication has different scope in ASP.NET and uses different cookies). If you are using forms authentication then you can change this cookie name using name attribute in authentication configuration element.
For session cookie to get generated, you must write some value into your session. Once session cookie gets generated, you can see it traversing in each request. BTW, you have to enable ASP.NET compatibility mode for participating in ASP.NET pipeline (including session state) in WCF services.
Upvotes: 2