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
    yesterday














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
    yesterday












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 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
















  • 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

















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



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


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














































































這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3