Created
October 5, 2015 21:54
-
-
Save bjoerntx/ae044f91e46fec6f2308 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Uri uri = new Uri("http://" + | |
Request.Url.Authority + "/Home/SaveTemplate"); | |
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); | |
// get the AuthCookie | |
var authCookie = | |
FormsAuthentication.GetAuthCookie(User.Identity.Name, true); | |
// create a new Cookie | |
Cookie requestAuthCoockie = new Cookie() | |
{ | |
Expires = authCookie.Expires, | |
Name = authCookie.Name, | |
Path = authCookie.Path, | |
Secure = authCookie.Secure, | |
Value = authCookie.Value, | |
Domain = uri.Host, | |
HttpOnly = authCookie.HttpOnly, | |
}; | |
// add the AuthCookie to the WebRequest | |
request.CookieContainer = new CookieContainer(); | |
request.CookieContainer.Add(requestAuthCoockie); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment