Skip to content

Instantly share code, notes, and snippets.

@ahall
Created April 19, 2012 12:28
Show Gist options
  • Save ahall/2420702 to your computer and use it in GitHub Desktop.
Save ahall/2420702 to your computer and use it in GitHub Desktop.
public class SessionPostAttribute : RequestFilterAttribute
{
public SessionPostAttribute()
{
this.Priority = -200;
this.ApplyTo = ApplyTo.Post;
}
public override void Execute(IHttpRequest req, IHttpResponse res, object requestDto)
{
var ssId = req.FormData.Get("ServiceStackId");
var ssPid = req.FormData.Get("ServiceStackPid");
if ((ssId != null) && (ssPid != null))
{
req.Cookies["ss-id"] = new System.Net.Cookie("ss-id", ssId);
req.Cookies["ss-pid"] = new System.Net.Cookie("ss-pid", ssPid);
}
}
}
[SessionPost, RequiredRole("admin")]
public class BlahService : IService<Blah>, IRequiresRequestContext
{
public IRequestContext RequestContext { get; set; }
public object Execute(Blah request)
{
Console.WriteLine("Made it through auth");
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment