Skip to content

Instantly share code, notes, and snippets.

@aliostad
Created January 28, 2013 13:26
Show Gist options
  • Save aliostad/4655476 to your computer and use it in GitHub Desktop.
Save aliostad/4655476 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
namespace Mvc4Application2.Controllers
{
public class ValuesController : ApiController
{
// GET api/values
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/values/5
public string Get(int id)
{
return "value";
}
public async Task<string> GetAsync(int id, string name)
{
Thread.CurrentPrincipal = new ClaimsPrincipal();
var cl = new HttpClient();
HttpResponseMessage res = await cl.GetAsync("http://google.com");
string s = await res.Content.ReadAsStringAsync();
var p = Thread.CurrentPrincipal; // THIS IS GENERIC principal!!!!
return s;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment