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
Nov 10 at 10:20
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 Nov 10 at 15:43
asked Nov 10 at 9:10
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
Nov 10 at 10:20
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
Nov 10 at 10:20
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
Nov 10 at 10:20
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
Nov 10 at 10:20
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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
Nov 10 at 10:20