这是ascx用户控件,我正在尝试执行ajax请求然后点击控制器但是我有一个问题和错误消息我找不到这个CreateSubscribe/Create
404(未找到)错误消息。
任何建议
<input type="text" id="subscribe-form-email" name="email" class="bg-transparent text-small no-margin border-color-medium-dark-gray" placeholder="Enter your email...">
<button id="button-subscribe-newsletter" type="button" class="btn btn-arrow-small position-absolute border-color-medium-dark-gray">
<i class="fa fa-caret-right no-margin-left"></i></button>
<script type="text/javascript">
$("#button-subscribe-newsletter").click(function () {
debugger
if ($('#subscribe-form-email').val().length > 0)
{
var dataToPost = {
subscriberemail: $("#subscribe-form-email").val(),
}
$.ajax({
dataType: "json",
url: 'CreateSubscribe/Create',
type: 'post',
data: JSON.stringify(dataToPost),
success: function (result) {
if (result) {
$("#Subscribe-Area").hide();
$("#Success-Message").show();
}
else {
$("#Failed-Message").show();
}
},
error:function
(err)
{
alert(err.message);
}
});
}
});
</script>
这是控制器
public class CreateSubscribeController : Controller
{
// GET: CreateSubscribe
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Create(string subscriberemail)
{
var keys = new Dictionary<string, string>() {
{ "Email",subscriberemail }
};
if (SitefinityWebApp.Helpers.SitefinityHelper.CreateSubscriberAndAddToMailingList(MailList.Maillist, subscriberemail))
{
SitefinityWebApp.Helpers.SitefinityHelper.SendEmailByTemplate(EmailTemplates.SubscribeEmail, subscriberemail, keys);
return Json(new { val = true }, JsonRequestBehavior.AllowGet);
}
else
{
return Json(new { val = false }, JsonRequestBehavior.AllowGet);
}
}