Hi,
Using Microsoft Identity and implemented Vote application from this article.
But I getting error in my http handler when trying to create repository.
Any idea?
<%@ WebHandler Language="C#" Class="Vote" %> using System; using System.Web; using System.Web.Security; using System.Security.Permissions; using System.Web.Script.Serialization; using Microsoft.AspNet.Identity; [PrincipalPermission(SecurityAction.Demand, Authenticated = true)] public class Vote : IHttpHandler { public void ProcessRequest (HttpContext context) { // Make sure voteValue is -1, 0, or 1 if (string.IsNullOrEmpty(context.Request.QueryString["articleId"])) throw new ArgumentException("articleId not supplied"); if (string.IsNullOrEmpty(context.Request.QueryString["voteValue"])) throw new ArgumentException("voteValue not supplied"); var articleId = Convert.ToInt32(context.Request.QueryString["articleId"]); var voteValue = Convert.ToInt32(context.Request.QueryString["voteValue"]); if (voteValue < -1 || voteValue > 1) throw new ArgumentException(string.Format("Invalid voteValue, {0}. Expected -1, 0, or 1.", voteValue)); if (HttpContext.Current.User.Identity.IsAuthenticated) { var userId = HttpContext.Current.User.Identity.GetUserId(); // Record the vote and get the new cumulative vote score for this article var newVoteScore = ArticleRepository.Vote(articleId, voteValue, userId); // Return the new cumulative vote score for this article var jsonSerializer = new JavaScriptSerializer(); context.Response.ContentType = "application/json"; context.Response.Write(jsonSerializer.Serialize(new { NewVoteScore = newVoteScore })); } } private ArticleRepository _articleRepository = null; //Error in here "Request for principal permission failed" public ArticleRepository ArticleRepository { get { if (_articleRepository == null) _articleRepository = new ArticleRepository(); return _articleRepository; } } public bool IsReusable { get { return false; } } }