2017-07-10 3 views
-1

localhostでは正常に動作していますが、デプロイ後は動作しません。ここで私はタイプを使用しています:私は、コントローラから削除するにjQueryを使用しています削除し、それでも取得し、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"); 
     } 

ですlocalhostでは動作しますが、デプロイ側では動作しません。

+0

がASアプリの設定です解決以下のようにそれを書いて、どうもありがとうございましたIISまたは仮想ディレクトリ内のアプリケーション。そして、デフォルトWebサイトの直下にありますか? –

+0

は、既定のWebサイトのIISでのアプリケーションとして –

答えて

0

次のように使用:

url: '@Url.Action("DoDelete","User",new RouteValueDictionary(new { id = Model.ID}))', 

または

url: '@Url.Action("DoDelete", "User", new { id = Model.ID})', 
+0

これは正解かもしれませんが、コードのみの回答は投稿しないでください。 *なぜ*これがユーザーの問題を修正するか説明してください。 –

0

以下のように使用することは問題

var newUrl='@Url.Action("DoDelete","User")?id='[email protected]; 
関連する問題