Asp.net Ajax Delete a record that does not work on Production Server

I am using this Ajax code to delete an entry. The code runs fine on the local host, while it constantly requests credentials on a hosted server.

enter image description here

and in the windows

enter image description here

With all the interlocutors of the participants, I basically suspect now for two reasons.

1) Web hosting is a cheap snapshot and is not updated for application rights, despite several efforts (you need to contact server level support)

2) Probably, some authentication token is required for the message box, for example this

$(document).ready(function () { $('.js-delete').on('click', function () { var button = $(this); var buttonId = button.attr("data-id"); //var container = $(this).parent().siblings('#tablex').find('#hiddenTable').clone(); var box = bootbox.dialog({ show: false, message: "Are you sure you want to delete the Record?", title: "Delete Record?", buttons: { cancel: { label: "Cancel", className: "btn-default" }, ok: { label: "Delete", className: "confirm btn btn-danger", callback: function (result) { if (result) { $.ajax({ url: "/api/datax/delete/" + button.attr("data-id"), method: "Delete", success: function () { button.parents("tr").remove(); } }); } console.log('Button Pressed.'); } } } }); }); }); 

And in my controller, I handle this delete request as follows.

  [Route("api/datax/delete/{id}")] public void Delete(int id) { var dataInDb = _context.Datax.SingleOrDefault(c => c.Id == id); if (dataInDb == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } _context.Datax.Remove(dataInDb); _context.SaveChanges(); } 
+7
jquery ajax
source share
3 answers

If the insert and updates work fine on the production server, then there can be no problem with the Connection string in Web.config.

  • Try manually deleting the entries from the database logging as the user whose credentials you use in Web.Config while working with the production server, and check the weather that allows or not. If this is not allowed, you need to grant delete rights along with read / write to the SQL server.
+5
source share

1) Check if HTTP-Delete-Method is enabled on the web server

2) Is the domain part of the interface different from the web service? If so, check your console’s output for errors regarding CORS, which means the browser thinks you're running multiple cross-site scripts

3) Internet Explorer encountered a problem with Kerboros-Authentication. The browser did not transmit authentication tokens. Not sure if this is a screenshot of IE, but if so, check if the following settings have changed behavior:

Advanced => Internet Settings => Advanced => Security: "Enable Integrated Windows Authentication" and "Enable Advanced Protection Mode" (or something similar, I translated the names from Germany)

+1
source share

Have you tried adding basic authentication to ajax beforeSend for pop-up authentication?

beforeSend: function (xhr) { xhr.setRequestHeader ("Authorization", "Basic " + btoa(username + ":" + password)); }

+1
source share

All Articles