我有一个名为广告的类:
public class Advertisement
{
public string Title { get; set; }
public string Desc { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在我的控制器中:
public class OrderController : ApiController
{
public UserManager<IdentityUser> UserManager { get; private set; }
// Post api/Order/Test
[Route("Test")]
public IHttpActionResult Test(Advertisement advertisement)
{
var currentUser = User.Identity.GetUserId();
Task<IdentityUser> user = UserManager.FindByIdAsync(currentUser);
return Ok(User.Identity.GetUserId());
}
Run Code Online (Sandbox Code Playgroud)
但是当我用Postman测试它时我遇到了这个错误,
"Message": "The request contains an entity body but no Content-Type header. The inferred media type 'application/octet-stream' is not supported for this resource.",
"ExceptionMessage": "No …
Run Code Online (Sandbox Code Playgroud) 嘿伙计我正在使用Autofac作为IOC,这是我的结构:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdTudent.Repo
{
public interface IRepository
{
IAdvertisementRepository Advertisements { get; set; }
IProfileRepository Profiles { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
我的存储库类是:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdTudent.Repo
{
public class Repositories : IRepository
{
public Repositories(IAdvertisementRepository advertisementRepository,
IProfileRepository profileRepository)
{
Advertisements = advertisementRepository;
Profiles = profileRepository;
}
public IAdvertisementRepository Advertisements { get; set; }
public IProfileRepository Profiles { get; set; }
} …
Run Code Online (Sandbox Code Playgroud) asp.net-mvc dependency-injection autofac neo4jclient asp.net-web-api2