它在localhost上正常工作,但在部署後無法工作。我使用jQuery從控制器刪除:在這裏,我使用的類型:刪除,但即使是GET,POST沒有什麼工作ajax在遠程端不能工作,但在mvc.net的localhost上工作
$("#btnDelete").click(function (e) {
e.preventDefault();
//alert("delete button clicked");
bootbox.confirm("Do you really want to delete this User", function(result) {
if (result) {
$.ajax({
url: "User/DoDelete/"[email protected],
type:"Delete",
success: function() {
// bootbox.alert("USer "+ @Model.ID+" Deleted successFully");
window.location.href = '@Url.Action("Index","User")';
},
error:function() {
bootbox.alert("Error");
}
});
}
});
});
和我的控制器是
[HttpDelete]
public ActionResult DoDelete(int id)
{
context = new Cost();
UserEmployee user = context.UserEmployees.Where(x => x.ID == id).FirstOrDefault();
if (user == null)
{
return HttpNotFound();
}
try
{
context.UserEmployees.Remove(user);
context.SaveChanges();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
return RedirectToAction("Index");
}
我不明白爲什麼它是在本地主機上工作,但不在部署方面。
是應用程序設置爲應用程序在IIS或虛擬目錄中。並且,直接在默認網站下? –
作爲默認網站中IIS的應用程序 –