I'm getting a 500 status code response when I update ajax ASP.NET MVC Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to get the current user in ASP.NET MVCHow to get ELMAH to work with ASP.NET MVC [HandleError] attribute?How to get all Errors from ASP.Net MVC modelState?Getting full URL of action in ASP.NET MVCHow can I get jQuery validation to produce the same markup as server-side ASP .NET MVC validation?How can I get the client's IP address in ASP.NET MVC?need to change the class of a label when an error occurs using data annotationsWhat is the error in my Validation in asp.net application?How propagate HTMLAttributes to a custom EditorTemplate?Why does my input not get validated when I'm not utilizing razor Html helpers?
SQL Query not selecting all points that it should?
As an international instructor, should I openly talk about my accent?
What's the difference between using dependency injection with a container and using a service locator?
Check if a string is entirely made of the same substring
Map material from china not allowed to leave the country
"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?
Flash for group photos near wall
What *exactly* is electrical current, voltage, and resistance?
Putting Ant-Man on house arrest
My bank got bought out, am I now going to have to start filing tax returns in a different state?
What do you call the part of a novel that is not dialog?
Why did C use the -> operator instead of reusing the . operator?
Is there any hidden 'W' sound after 'comment' in : Comment est-elle?
How to count in linear time worst-case?
How to not starve gigantic beasts
Seek and ye shall find
What is the term for a person whose job is to place products on shelves in stores?
Error: Syntax error. Missing ')' for CASE Statement
"My boss was furious with me and I have been fired" vs. "My boss was furious with me and I was fired"
What is ls Largest Number Formed by only moving two sticks in 508?
c++ diamond problem - How to call base method only once
Do I need to protect SFP ports and optics from dust/contaminants? If so, how?
What to do with someone that cheated their way through university and a PhD program?
Suing a Police Officer Instead of the Police Department
I'm getting a 500 status code response when I update ajax ASP.NET MVC
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to get the current user in ASP.NET MVCHow to get ELMAH to work with ASP.NET MVC [HandleError] attribute?How to get all Errors from ASP.Net MVC modelState?Getting full URL of action in ASP.NET MVCHow can I get jQuery validation to produce the same markup as server-side ASP .NET MVC validation?How can I get the client's IP address in ASP.NET MVC?need to change the class of a label when an error occurs using data annotationsWhat is the error in my Validation in asp.net application?How propagate HTMLAttributes to a custom EditorTemplate?Why does my input not get validated when I'm not utilizing razor Html helpers?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I want to update my user information but I'm getting an error
500 status code response
when I'm updating my data.
This is my code:
Context class:
public void Update(UserInformation model)
var user = _db.UserInfo
.FirstOrDefault(m_id => m_id.Id == model.Id);
_db.Update(user);
_db.SaveChanges();
Controller:
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> PostEdit(UserInformation userInformation)
if (!ModelState.IsValid)
_ui_context.Update(userInformation);
return new JsonResult("User Updated!");
My AJAX call:
if (action == "Update")
$.ajax(
method: "POST",
url: "/UserInformation/PostEdit",
data: $('#form_data').serialize(),
dataType: "JSON",
success: function (data)
alert(data);
clearFields();
$("#exampleModal").modal("hide");
loadUser();
);
Then this is my view on modal:
<form method="POST" id="form_data">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Id" />
<input type="hidden" id="action_value" value="" />
<div class="form-group">
<label asp-for="FirstName" class="control-label"></label>
<input asp-for="FirstName" class="form-control" id="txtFirst" />
<span asp-validation-for="FirstName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="LastName" class="control-label"></label>
<input asp-for="LastName" class="form-control" id="txtLast" />
<span asp-validation-for="LastName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Location" class="control-label"></label>
<input asp-for="Location" class="form-control" id="txtLocation" />
<span asp-validation-for="Location" class="text-danger"></span>
</div>
</form>
This is the error I am getting:

Thank you for your answer! Appreciate it much
c# asp.net-mvc asp.net-ajax
add a comment |
I want to update my user information but I'm getting an error
500 status code response
when I'm updating my data.
This is my code:
Context class:
public void Update(UserInformation model)
var user = _db.UserInfo
.FirstOrDefault(m_id => m_id.Id == model.Id);
_db.Update(user);
_db.SaveChanges();
Controller:
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> PostEdit(UserInformation userInformation)
if (!ModelState.IsValid)
_ui_context.Update(userInformation);
return new JsonResult("User Updated!");
My AJAX call:
if (action == "Update")
$.ajax(
method: "POST",
url: "/UserInformation/PostEdit",
data: $('#form_data').serialize(),
dataType: "JSON",
success: function (data)
alert(data);
clearFields();
$("#exampleModal").modal("hide");
loadUser();
);
Then this is my view on modal:
<form method="POST" id="form_data">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Id" />
<input type="hidden" id="action_value" value="" />
<div class="form-group">
<label asp-for="FirstName" class="control-label"></label>
<input asp-for="FirstName" class="form-control" id="txtFirst" />
<span asp-validation-for="FirstName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="LastName" class="control-label"></label>
<input asp-for="LastName" class="form-control" id="txtLast" />
<span asp-validation-for="LastName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Location" class="control-label"></label>
<input asp-for="Location" class="form-control" id="txtLocation" />
<span asp-validation-for="Location" class="text-danger"></span>
</div>
</form>
This is the error I am getting:

Thank you for your answer! Appreciate it much
c# asp.net-mvc asp.net-ajax
add a comment |
I want to update my user information but I'm getting an error
500 status code response
when I'm updating my data.
This is my code:
Context class:
public void Update(UserInformation model)
var user = _db.UserInfo
.FirstOrDefault(m_id => m_id.Id == model.Id);
_db.Update(user);
_db.SaveChanges();
Controller:
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> PostEdit(UserInformation userInformation)
if (!ModelState.IsValid)
_ui_context.Update(userInformation);
return new JsonResult("User Updated!");
My AJAX call:
if (action == "Update")
$.ajax(
method: "POST",
url: "/UserInformation/PostEdit",
data: $('#form_data').serialize(),
dataType: "JSON",
success: function (data)
alert(data);
clearFields();
$("#exampleModal").modal("hide");
loadUser();
);
Then this is my view on modal:
<form method="POST" id="form_data">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Id" />
<input type="hidden" id="action_value" value="" />
<div class="form-group">
<label asp-for="FirstName" class="control-label"></label>
<input asp-for="FirstName" class="form-control" id="txtFirst" />
<span asp-validation-for="FirstName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="LastName" class="control-label"></label>
<input asp-for="LastName" class="form-control" id="txtLast" />
<span asp-validation-for="LastName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Location" class="control-label"></label>
<input asp-for="Location" class="form-control" id="txtLocation" />
<span asp-validation-for="Location" class="text-danger"></span>
</div>
</form>
This is the error I am getting:

Thank you for your answer! Appreciate it much
c# asp.net-mvc asp.net-ajax
I want to update my user information but I'm getting an error
500 status code response
when I'm updating my data.
This is my code:
Context class:
public void Update(UserInformation model)
var user = _db.UserInfo
.FirstOrDefault(m_id => m_id.Id == model.Id);
_db.Update(user);
_db.SaveChanges();
Controller:
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> PostEdit(UserInformation userInformation)
if (!ModelState.IsValid)
_ui_context.Update(userInformation);
return new JsonResult("User Updated!");
My AJAX call:
if (action == "Update")
$.ajax(
method: "POST",
url: "/UserInformation/PostEdit",
data: $('#form_data').serialize(),
dataType: "JSON",
success: function (data)
alert(data);
clearFields();
$("#exampleModal").modal("hide");
loadUser();
);
Then this is my view on modal:
<form method="POST" id="form_data">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Id" />
<input type="hidden" id="action_value" value="" />
<div class="form-group">
<label asp-for="FirstName" class="control-label"></label>
<input asp-for="FirstName" class="form-control" id="txtFirst" />
<span asp-validation-for="FirstName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="LastName" class="control-label"></label>
<input asp-for="LastName" class="form-control" id="txtLast" />
<span asp-validation-for="LastName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Location" class="control-label"></label>
<input asp-for="Location" class="form-control" id="txtLocation" />
<span asp-validation-for="Location" class="text-danger"></span>
</div>
</form>
This is the error I am getting:

Thank you for your answer! Appreciate it much
c# asp.net-mvc asp.net-ajax
c# asp.net-mvc asp.net-ajax
edited Mar 9 at 5:46
ArunPratap
1,76031128
1,76031128
asked Mar 8 at 2:33
Paul Vincent DoroyanPaul Vincent Doroyan
104
104
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The 500 status that mean there is exception inside PostEdit() action. Please check your model userInformation pass into method _ui_context.Update(userInformation);
You can change
if (!ModelState.IsValid)
return new JsonResult("Model is invalid");
I found it already my problem now is my data is not updating on database
– Paul Vincent Doroyan
Mar 8 at 2:47
add a comment |
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',
autoActivateHeartbeat: false,
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
);
);
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%2f55055901%2fim-getting-a-500-status-code-response-when-i-update-ajax-asp-net-mvc%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The 500 status that mean there is exception inside PostEdit() action. Please check your model userInformation pass into method _ui_context.Update(userInformation);
You can change
if (!ModelState.IsValid)
return new JsonResult("Model is invalid");
I found it already my problem now is my data is not updating on database
– Paul Vincent Doroyan
Mar 8 at 2:47
add a comment |
The 500 status that mean there is exception inside PostEdit() action. Please check your model userInformation pass into method _ui_context.Update(userInformation);
You can change
if (!ModelState.IsValid)
return new JsonResult("Model is invalid");
I found it already my problem now is my data is not updating on database
– Paul Vincent Doroyan
Mar 8 at 2:47
add a comment |
The 500 status that mean there is exception inside PostEdit() action. Please check your model userInformation pass into method _ui_context.Update(userInformation);
You can change
if (!ModelState.IsValid)
return new JsonResult("Model is invalid");
The 500 status that mean there is exception inside PostEdit() action. Please check your model userInformation pass into method _ui_context.Update(userInformation);
You can change
if (!ModelState.IsValid)
return new JsonResult("Model is invalid");
edited Mar 8 at 2:47
answered Mar 8 at 2:46
Hien NguyenHien Nguyen
3,6841820
3,6841820
I found it already my problem now is my data is not updating on database
– Paul Vincent Doroyan
Mar 8 at 2:47
add a comment |
I found it already my problem now is my data is not updating on database
– Paul Vincent Doroyan
Mar 8 at 2:47
I found it already my problem now is my data is not updating on database
– Paul Vincent Doroyan
Mar 8 at 2:47
I found it already my problem now is my data is not updating on database
– Paul Vincent Doroyan
Mar 8 at 2:47
add a comment |
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.
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%2f55055901%2fim-getting-a-500-status-code-response-when-i-update-ajax-asp-net-mvc%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