Asp.Net Core 3.0 Ajax Call İşlemleri

Merhabalar,

.NET Framework MVC ile Jquery üzerinden ajax call etme işlemleri ile .Net Core arasında çok bir fark olmasada ufak tefek farklılıkları aktarmak istedim.

Js kodlarımız;

function serversFormPost() {
    var frm = $('#frmServers');

    $.ajax({
        type: "POST",
        url: "/Settings/ServersAddEditAjax",
        data: frm.serialize(),
        success: function (data) {
            if (data.returnCode === 0) {
                formClear();
                $("#pResultText").html('<div class="alert aletr-block alert-success"><button id="btnAlertClose" type="button" class="close" data-dismiss="alert"><i class="ace-icon fa fa-times"></i></button><p>' + data.returnMessages + '</p></div>');
            } else {
                $("#pResultText").html('<div class="alert aletr-block alert-warning"><button id="btnAlertClose" type="button" class="close" data-dismiss="alert"><i class="ace-icon fa fa-times"></i></button><p>' + data.returnMessages + '</p></div>');
            }
        }
    });
}

function formClear() {
    $("#btnAlertClose").click();
    $('#frmServers')[0].reset();
}


Cshtml kodlarımız;

<form id="frmServers">
@Html.AntiForgeryToken()
<input name="txtHiddenServerConnectionId" type="hidden" id="txtHiddenServerConnectionId" value="0">
<div class="form-group">
    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">Access Name </label>
    <div class="col-sm-9">
        <input name="txtAccessName" type="text" id="txtAccessName" class="col-xs-10 col-sm-11" placeholder="Cluster/Stand Alone Access Name">
    </div>
</div>
<div class="form-group">
    <label class="col-sm-3 control-label no-padding-right">Access Ip</label>
    <div class="col-sm-9">
        <input name="txtAccessIp" type="text" id="txtAccessIp" class="col-xs-10 col-sm-11" placeholder="Cluster/Stand Alone Ip">
    </div>
</div> 
<div class="form-group">
    <label class="col-sm-3 control-label no-padding-right">User</label>
    <div class="col-sm-9">
        <input name="txtConnectionUser" type="text" id="txtConnectionUser" class="col-xs-10 col-sm-11" placeholder="User to connect this server">
    </div>
</div>
<div class="form-group">
    <label class="col-sm-3 control-label no-padding-right">Password</label>
    <div class="col-sm-9">
        <input name="txtEncryptedPassword" type="password" id="txtEncryptedPassword" class="col-xs-10 col-sm-11">
    </div>
</div>
<div class="clearfix"></div>
<div class="space-8"></div>
<div class="widget-toolbox padding-4 clearfix">
  <div class="btn-group" style="padding:5px;">
      <a id="btnSave" class="btn btn-xs btn-primary  ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" href="javascript:void(0);" onclick="serversFormPost();">Save</a>
      <a id="btnClear" class="btn btn-xs  ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" href="javascript:void(0);" onclick="formClear();">Clear</a>
  </div>
</div>
</form>


Controller.cs kodlarımız;

[HttpPost]
[ValidateAntiForgeryToken]
public JsonResult ServersAddEditAjax(IFormCollection formCollection)
{
    ServerConnectionsDto model = new ServerConnectionsDto()
    {
        ServerConnectionId = int.Parse(formCollection["txtHiddenServerConnectionId"]),
        AccessName = formCollection["txtAccessName"],
        AccessIp = formCollection["txtAccessIp"],
        HasConnection = (formCollection["chkHasConnection"].ToString() == "on" ? true : false),
        ConnectionType = formCollection["ddlConnectionType"],
        ConnectionUser = formCollection["txtConnectionUser"]
    };

    ServerConnectionsRepository serverConnections = new ServerConnectionsRepository(Configuration);
    return Json(serverConnections.AddEditServerConnections(model));
}


Anlatacaklarım bukadar kolaylıklar dilerim.