如果使用的不是Admin时,如何将web api控制器重定向到mvc主控制器。如果身份角色不是管理员,则从Web Api重定向到MVC控制器
// GET api/adminleave
public IEnumerable<ObjectModel> GetPendingLeave()
{
if (!User.IsInRole("Admin"))
{
var response = Request.CreateResponse(HttpStatusCode.Moved);
response.Headers.Location = new Uri("example.com");
return response;
}
List<ObjectModel> obj=new List<ObjectModel>();
return obj;
}
我按照上面的方法尝试,但出现错误。
错误27无法隐式转换类型 'System.Net.Http.HttpResponseMessage' 到 'System.Collections.Generic.IEnumerable'。 的显式转换存在(是否缺少 投?)F:\ WebPortal \ WebApplication1 \ \控制器离开\ AdminLeaveController.cs 34 24 WebApplication的
我如何可以重定向形式坎的WebAPI控制器,当我返回来自webAPI控制器的对象列表