0
Windows 인증을 사용 중이며이 odata 컨트롤러에서 정상적으로 작동하고 있습니다. 그러나 최신 NuGet 패키지 (시험판 5.0.0-rc1)를 얻은 후 뭔가 바뀌었고 ApiController.User
이 null입니다. 더 이상 Windows 인증을 통과하지 않습니다. 어떤 아이디어? [Authorize] 속성을 추가하려고 시도했지만 작동하지 않습니다. 어딘가에 다른 설정이 필요합니다.odata ApiController.User == 웹 API 5.0.0-rc1로 업그레이드 한 후 NULL =
public class ProductsController : EntitySetController<Product, int>
{
protected ProjectContextUnitOfWork UoW;
protected UserRepository UserRepo;
protected ProductRepository ProductRepo;
protected Project.Models.User CurrentUser;
// odata/Products/
public ProductsController()
{
if (!User.Identity.IsAuthenticated)
{
HttpResponseMessage msg = Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "User not authenticated.");
throw new HttpResponseException(msg);
}
ProjectUserPrincipal LoggedInUser = this.User as ProjectUserPrincipal;
// - closed in Dispose()
UoW = new ProjectContextUnitOfWork(false); //without lazy loading
UserRepo = new UserRepository(UoW);
ProductRepo = new ProductRepository(UoW);
CurrentUser = UserRepo.Get(LoggedInUser.Username, LoggedInUser.Domain);
}
protected override Product GetEntityByKey(int id)
{
var x = from b in ProductRepo.GetAvailableProductsWithNumbers(CurrentUser)
where b.Id == id
select b;
return x.FirstOrDefault();
}
...
}
기타 세부 사항 : 난 다시 5.0.0.beta2에 복귀 할 때
- 는 .NET 4.5
- 웹 작동, 다른 변경하지 않고, 또한
양식 다시. 따라서 Microsoft.AspNet.WebApi
의 변경 사항입니다. 코드를 변경해도 괜찮습니다. 팁이 필요합니다. 감사!