Bad Request error returns “error” instead of the error message when https is enabled in IIS
up vote
0
down vote
favorite
I have an ASP .NET MVC 4 web site hosted on IIS 10.0. The action methods in controllers validate the input and if the input is not proper, the action method returns a Bad Request status code (400) along with error message. The code for this is like below
public ActionResult SaveCustomer(Customer customer)
var message = string.Empty
var isValid = ValidateCustomer(customer, ref message);
if (!isValid)
return new HttpStatusCodeResult(HttpStatusCode.BadRequest,message);
//Remaining code to save customer
The client side code uses JQuery AJAX requests and is like below
var customer = ;
// Code to fill the customer object
$.post('/customer/savecustomer', customer, function (data)
alert('Customer saved');
).error(function (response)
alert(response.statusText);
);
The response.statusText displays the error message set in the action method as long as the site is using http. However once the site is configured with https, the response.statusText returns only "error".
I tried using solution mentioned here but it does not work.
ASP.NET MVC 5 ajax error statusText is always "error"
When I open Network Tab in the Chrome Developer Tools, this is what I find:
With HTTP Enabled
Headers tab
Request URL: http://example.com/Customer/SaveCustomer
Request Method: POST
Status Code: 400 Error Message sent from server
Remote Address: xxxx.xxxx.xxxx.xxxx:80
Referrer Policy: no-referrer-when-downgrade
Response tab
Bad Request
With HTTPS Enabled
Headers tab
Request URL: https://example.com/Customer/SaveCustomer
Request Method: POST
Status Code: 400
Remote Address: xxxx.xxxx.xxxx.xxxx:443
Referrer Policy: no-referrer-when-downgrade
Response tab
Bad Request
The difference between http and https is the error message returned with status code with http and only status code returned with https.
Any ideas ?
c# jquery asp.net-mvc https bad-request
add a comment |
up vote
0
down vote
favorite
I have an ASP .NET MVC 4 web site hosted on IIS 10.0. The action methods in controllers validate the input and if the input is not proper, the action method returns a Bad Request status code (400) along with error message. The code for this is like below
public ActionResult SaveCustomer(Customer customer)
var message = string.Empty
var isValid = ValidateCustomer(customer, ref message);
if (!isValid)
return new HttpStatusCodeResult(HttpStatusCode.BadRequest,message);
//Remaining code to save customer
The client side code uses JQuery AJAX requests and is like below
var customer = ;
// Code to fill the customer object
$.post('/customer/savecustomer', customer, function (data)
alert('Customer saved');
).error(function (response)
alert(response.statusText);
);
The response.statusText displays the error message set in the action method as long as the site is using http. However once the site is configured with https, the response.statusText returns only "error".
I tried using solution mentioned here but it does not work.
ASP.NET MVC 5 ajax error statusText is always "error"
When I open Network Tab in the Chrome Developer Tools, this is what I find:
With HTTP Enabled
Headers tab
Request URL: http://example.com/Customer/SaveCustomer
Request Method: POST
Status Code: 400 Error Message sent from server
Remote Address: xxxx.xxxx.xxxx.xxxx:80
Referrer Policy: no-referrer-when-downgrade
Response tab
Bad Request
With HTTPS Enabled
Headers tab
Request URL: https://example.com/Customer/SaveCustomer
Request Method: POST
Status Code: 400
Remote Address: xxxx.xxxx.xxxx.xxxx:443
Referrer Policy: no-referrer-when-downgrade
Response tab
Bad Request
The difference between http and https is the error message returned with status code with http and only status code returned with https.
Any ideas ?
c# jquery asp.net-mvc https bad-request
If you view the web response in Chrome Developer Tools (Network tab), what is the http status and payload returned for http? https? Please add both to your question (not as comments).
– mjwills
yesterday
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have an ASP .NET MVC 4 web site hosted on IIS 10.0. The action methods in controllers validate the input and if the input is not proper, the action method returns a Bad Request status code (400) along with error message. The code for this is like below
public ActionResult SaveCustomer(Customer customer)
var message = string.Empty
var isValid = ValidateCustomer(customer, ref message);
if (!isValid)
return new HttpStatusCodeResult(HttpStatusCode.BadRequest,message);
//Remaining code to save customer
The client side code uses JQuery AJAX requests and is like below
var customer = ;
// Code to fill the customer object
$.post('/customer/savecustomer', customer, function (data)
alert('Customer saved');
).error(function (response)
alert(response.statusText);
);
The response.statusText displays the error message set in the action method as long as the site is using http. However once the site is configured with https, the response.statusText returns only "error".
I tried using solution mentioned here but it does not work.
ASP.NET MVC 5 ajax error statusText is always "error"
When I open Network Tab in the Chrome Developer Tools, this is what I find:
With HTTP Enabled
Headers tab
Request URL: http://example.com/Customer/SaveCustomer
Request Method: POST
Status Code: 400 Error Message sent from server
Remote Address: xxxx.xxxx.xxxx.xxxx:80
Referrer Policy: no-referrer-when-downgrade
Response tab
Bad Request
With HTTPS Enabled
Headers tab
Request URL: https://example.com/Customer/SaveCustomer
Request Method: POST
Status Code: 400
Remote Address: xxxx.xxxx.xxxx.xxxx:443
Referrer Policy: no-referrer-when-downgrade
Response tab
Bad Request
The difference between http and https is the error message returned with status code with http and only status code returned with https.
Any ideas ?
c# jquery asp.net-mvc https bad-request
I have an ASP .NET MVC 4 web site hosted on IIS 10.0. The action methods in controllers validate the input and if the input is not proper, the action method returns a Bad Request status code (400) along with error message. The code for this is like below
public ActionResult SaveCustomer(Customer customer)
var message = string.Empty
var isValid = ValidateCustomer(customer, ref message);
if (!isValid)
return new HttpStatusCodeResult(HttpStatusCode.BadRequest,message);
//Remaining code to save customer
The client side code uses JQuery AJAX requests and is like below
var customer = ;
// Code to fill the customer object
$.post('/customer/savecustomer', customer, function (data)
alert('Customer saved');
).error(function (response)
alert(response.statusText);
);
The response.statusText displays the error message set in the action method as long as the site is using http. However once the site is configured with https, the response.statusText returns only "error".
I tried using solution mentioned here but it does not work.
ASP.NET MVC 5 ajax error statusText is always "error"
When I open Network Tab in the Chrome Developer Tools, this is what I find:
With HTTP Enabled
Headers tab
Request URL: http://example.com/Customer/SaveCustomer
Request Method: POST
Status Code: 400 Error Message sent from server
Remote Address: xxxx.xxxx.xxxx.xxxx:80
Referrer Policy: no-referrer-when-downgrade
Response tab
Bad Request
With HTTPS Enabled
Headers tab
Request URL: https://example.com/Customer/SaveCustomer
Request Method: POST
Status Code: 400
Remote Address: xxxx.xxxx.xxxx.xxxx:443
Referrer Policy: no-referrer-when-downgrade
Response tab
Bad Request
The difference between http and https is the error message returned with status code with http and only status code returned with https.
Any ideas ?
c# jquery asp.net-mvc https bad-request
c# jquery asp.net-mvc https bad-request
edited yesterday
asked yesterday
devanalyst
5051933
5051933
If you view the web response in Chrome Developer Tools (Network tab), what is the http status and payload returned for http? https? Please add both to your question (not as comments).
– mjwills
yesterday
add a comment |
If you view the web response in Chrome Developer Tools (Network tab), what is the http status and payload returned for http? https? Please add both to your question (not as comments).
– mjwills
yesterday
If you view the web response in Chrome Developer Tools (Network tab), what is the http status and payload returned for http? https? Please add both to your question (not as comments).
– mjwills
yesterday
If you view the web response in Chrome Developer Tools (Network tab), what is the http status and payload returned for http? https? Please add both to your question (not as comments).
– mjwills
yesterday
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237502%2fbad-request-error-returns-error-instead-of-the-error-message-when-https-is-ena%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
If you view the web response in Chrome Developer Tools (Network tab), what is the http status and payload returned for http? https? Please add both to your question (not as comments).
– mjwills
yesterday