Mẹo nhỏ: Để tìm kiếm chính xác các tác phẩm của Phebinhvanhoc.com.vn, hãy search trên Google với cú pháp: "Từ khóa" + "phebinhvanhoc". (Ví dụ: tác phẩm chí phèo phebinhvanhoc). Tìm kiếm ngay
159 lượt xem

7 tuyệt chiêu khắc phục lỗi 500 internal server error nhanh chóng

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Jan 24, 2017 03:54 PM|JagjitSingh|LINK Hi

I am getting this error :Failed to load resource: the server responded with a status of 500 (Internal Server Error) -http://localhost:15093/BookCa

function Delete(Id) { //alert(Id); $(“#delete-dialog”).dialog({ modal: true, closeOnEscape: false, width: 400, title: “Confirm”, buttons: { Continue: function () { $.ajax({ url: “/BookCategory/Delete/” + Id, //url: “BookCategory/Delete”, //data: “{Id: ” + Id + “}”, type: “POST”, dataType: “json”, success: function () { if (confirm(“Are you sure you want to delete !”) == true) { alert(“Data Deleted successfully”); } else { alert(“You have canceled the changes”); } //alert(“Data Updated successfully”); $dialog.dialog(“close”); }) }, error: function () { $(“#msg”).html(“”); } }); $(this).dialog(“close”); }, Close: function () { $(this).dialog(“close”); } }, });}Controller public ActionResult Delete(int Id) { bool status = false; string message = “”; var v = db.BookCategories.Where(a => a.Id.Equals(Id)).FirstOrDefault(); if (v != null) { db.BookCategories.Remove(v); db.SaveChanges(); status = true; //message = “Successfully Deleted!”; } else { return HttpNotFound(); } return new JsonResult { Data = new { status = status, message = message } }; }tegory/Delete/1003

Thanks

satish_nagde…Bạn đang xem: Failed to load resource: the server responded with a status of 500

Contributor

Re: Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Jan 24, 2017 04:12 PM|satish_nagdev|LINK Hi,

can you try following ? I hope you”re getting ID correctly in first commented //alert before #delete-dialogue

//url: “/BookCategory/Delete/” + Id,url: “BookCategory/Delete”,data: JSON.stringify{“Id”:Id},

*

JagjitSingh

Member

Re: Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Jan 24, 2017 04:30 PM|JagjitSingh|LINK Hi

I have written like this but still not working . I am getting correct value of Id.

Bạn đang xem: 7 tuyệt chiêu khắc phục lỗi 500 internal server error nhanh chóng

XEM THÊM:  Những câu nói hay nhức nhói của trấn thành

function Delete(Id) { //alert(Id); $(“#delete-dialog”).dialog({ modal: true, closeOnEscape: false, width: 400, title: “Confirm”, buttons: { Continue: function () { $.ajax({ type: “POST”, url: “/BookCategory/Delete”, data: “{Id:Id }”, dataType: “json”, success: function () { if (confirm(“Are you sure you want to delete !”) == true) { alert(“Data Deleted successfully”); } else { alert(“You have canceled the changes”); } $dialog.dialog(“close”); }, error: function () { $(“#msg”).html(“”); } }); $(this).dialog(“close”); }, Close: function () { $(this).dialog(“close”); } }, });}Controller // public ActionResult Delete(int Id) { bool status = false; string message = “”; //using (MyDatabaseEntities dc = new MyDatabaseEntities()) //{ var v = db.BookCategories.Where(a => a.Id.Equals(Id)).FirstOrDefault(); if (v != null) { db.BookCategories.Remove(v); db.SaveChanges(); status = true; } else { return HttpNotFound(); } //} return new JsonResult { Data = new { status = status, message = message } }; }

Thanks

*

PatriceSc

All-Star

Re: Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Jan 24, 2017 04:44 PM|PatriceSc|LINK Hi,

db is created in your controller constructor or could it be null? http 500 means that you have a server side exception which be default should have been written to the Windows event log. Then from the actual error message it should be easier to figure out what happens…

*

mgebhard

All-Star

Re: Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Jan 24, 2017 04:46 PM|mgebhard|LINK The confirm dialog is pointless since the AJAX success handler runs after the Delete command.

Try removing theValidateAntiForgeryToken attribute and retry. If removing theValidateAntiForgeryToken attribute works then you”ll need to implement a proper interface.

Xem thêm: Decal Cây Thông Noel Trang Trí Cây Thông Noel Trên Cửa Kính Đẹp 2020

XEM THÊM:  Những câu nói hay về thần tượng nữ

http://stackoverflow.com/questions/14473597/include-antiforgerytoken-in-ajax-post-Phebinhvanhoc.com.vn-net-mvc

Otherwise, continue to troubleshoot. Try breaking down the code into testable chunks until you find the bug.

Xem thêm: Cần Bán Đất Tại Nha Trang Gấp, Mua Bán Đất Khánh Hòa Giá Rẻ Tháng 07/2021

Contributor

Re: Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Jan 24, 2017 04:59 PM|satish_nagdev|LINK your data: parameter is not what I mentioned, not sure if you tried , 500 is indeed server side error, try debugging as suggested

data: “{Id:Id }”data: JSON.stringify{“Id”:Id},

Re: Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Oct 30, 2017 04:15 PM|andersw|LINK The error:”Failed to load resource: the server responded with a status of 500 (Internal Server Error)” happened to me after I added two mimeMap lines to my Web.config

I think in one way or another they conflicted with the runAllManagedModulesForAllRequestswith the result that my web page ended up in some kind of error before loading the .css and .js files (when using localhost). So it seems to be either the one or the others.(The problem with loading .js and .css was not present, when my .js and .css links in the head sectionof my program was written with an absolute paths i.e. starting with http:// But using this method would make it diffecult to test my program why developing it).

Chuyên mục: Nói hay

Thông báo: Phê Bình Văn Học ngoài phục vụ bạn đọc ở Việt Nam chúng tôi còn có kênh tiếng anh PhebinhvanhocEN cho bạn đọc trên toàn thế giới, mời thính giả đón xem.

Chúng tôi Xin cám ơn!

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *