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 ?










share|improve this question























  • 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














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 ?










share|improve this question























  • 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












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 ?










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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
















  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo