当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - MVC Controller returns HTML error page over HTTPS

问题描述:

I'm doing a POST in javascript to my MVC Controller. If something fails the server will catch the exception and return an error with the exception message. This works fine under HTTP. I enabled SSL on IIS Express, and all of a sudden the returned error contains the HTML of an error page, instead of the exception message.

What could be the cause of this?

This is in javascript:

var config = {

url: "https://localhost:44301/update",

type: "POST",

data: data

};

$.ajax(config).fail(function (error) {

// error.statusText contains exception.Message over HTTP

// error.statusText contains "OK" over HTTPS (IIS Express)

});

And this is on the server:

[HttpPost]

[Route("update")]

[ValidateAntiForgeryToken]

public ActionResult Update(int id)

{

try

{

Update(id);

}

catch (Exception exception)

{

return new HttpStatusCodeResult(HttpStatusCode.BadRequest, exception.Message);

}

}

分享给朋友:
您可能感兴趣的文章:
随机阅读: