【发布时间】:2021-01-12 17:24:20
【问题描述】:
我有一个 ActionMethod
[HttpGet]
[Route("ControllerName/IsUniqueNotificationName/{notificationName}")]
public IActionResult IsUniqueNotificationName(string notificationName)
{
var name = string.IsNullOrEmpty(notificationName);
var isUnique =
this.bannerNotificationService.IsUniqueNotificationName(notificationName);
return this.Json(isUnique);
}
我的 javascript 方法
checkUniqueNotificationname = function (emailElement) {
var notificationName = $(emailElement).val();
let uri = "BannerNotification/IsUniqueNotificationName/" + notificationName;
$.ajax({
type: "Get",
url: common.buildUrlWithBasePath(uri),
success: function (data) {
if (data == true) {
$("#BannerNotificationName").css({ "border-color": "black" });
$("#altFromMessageGroupValue").hide();
}
else {
$("#BannerNotificationName").css({ "border-color": "red" });
$("#altFromMessageGroupValue").show();
}
},
error: function () {
common.hideLoader();
}
});
};
当我得到 notificationName 值时,它会击中我的 ActionMethod,但是当我将 notificationName 作为空字符串时**(即;notificationName='')** 它没有击中我的端点。相反,它击中了另一个端点,看起来像
[Route("ControllerName/{banName}")]
[HttpGet]
public IActionResult Details(string banName)
{
}
有人可以帮我解决这个问题
【问题讨论】:
标签: javascript c# asp.net asp.net-mvc model-view-controller