with servicestack how can i prevent cookies being added to the response?

余生长醉 提交于 2019-12-07 13:46:50

问题


I can remove the cookies after the fact, with this:

public override void Configure(Funq.Container container)
{
    ResponseFilters.Add((req, res, dto) =>
    {
        ((HttpListenerResponse)res.OriginalResponse).Headers.Remove("Set-Cookie");
    });
}

I have also considered overriding the SetCookie method of HttpResponse to just ditch the cookies, but I am not sure how to override that behaviour in servicestack.

Question: How can I ensure no cookies are added to my responses in the first place? This seems more efficient and fit-to-intent than the above.

Background:

I am using Basic Authentication, but I do not need to persist sessions, or want to allow any kind of authentication via cookies. Clients must re-authenticate each request.

So, another approach might also work, such as a custom session factory that returns null sessions? Or some other way of overriding session/authentication handling. However, despite much digging, I have had no success on that front, either.

Thanks in advance!

来源:https://stackoverflow.com/questions/16183619/with-servicestack-how-can-i-prevent-cookies-being-added-to-the-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!