Я только что развернул свое приложение ASP.NET на удаленном сервере с хостинговой компанией, и когда я пытаюсь отправить свой запрос POST в почтальоне на мой URL, я получаю внутреннюю ошибку сервера со следующим сообщением об ошибке.
"Сообщение": "Произошла ошибка."
"ExceptionMessage": "Буфер не может быть нулевым. Имя параметра: буфер"
"ExceptionType": "Система.ArgumentNullException "
Информация StackTrace указывает на мой AccountController в строке 334.
ниже - мой AccountController:
public async Task<IHttpActionResult> Register(RegisterBindingModel model)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
else
{
var stream = new MemoryStream(model.ImageArray);//This is the line the StackTrace Points to
var guid = Guid.NewGuid().ToString();
var file = string.Format("{0}.jpg", guid);
var folder = "~\\Content\\UserData";
var fullpath = string.Format("{0}\\{1}", folder, file);
var response = Filehelpers.UploadPhoto(stream, folder, file);
var user = new ApplicationUser()
{
UserName = model.Alias,
Email = model.Email,
Alias = model.Alias,
PhoneNumber = model.PhoneNumber,
DateJoined = model.DateJoined,
ImagePath = fullpath
};
IdentityResult result = await UserManager.CreateAsync(user, model.Password);
if (!result.Succeeded)
{
return GetErrorResult(result);
}
return Ok();
Вот моя модель:
[Required]
[Display(Name = "Email")]
public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
//custom models
//represents the username
public string Alias { get; set; }
//represents when the user signed up
public DateTime DateJoined { get; set; }
//represents users profile picture
[NotMapped]
public byte[] ImageArray { get; set; }
//represents the uri of the users picture
public string ImagePath { get; set; }
public string PhoneNumber { get; set; }
}
PS: локально все работало нормально, когда я тестировал, но начал выдавать ошибку, когда я развернул и хотел проверить.