【问题标题】:NopCommerce action not found on production works on localhost在本地主机上的生产工作中找不到 NopCommerce 操作
【发布时间】:2017-06-25 04:13:54
【问题描述】:

我现在已经没有关于如何解决这个问题的想法了。由于某种原因,操作名称在生产服务器上不可用。我不断收到 500 个内部服务器错误。 我尝试使用邮递员和restClient,但每个工具都返回相同的错误,适用于本地主机。我做错了什么?

注意:所有评论都是我已经尝试过的。

控制器客户 - 操作代码:

    //[AcceptVerbs(HttpVerbs.Get)]  
    [NopHttpsRequirement(SslRequirement.Yes)]  
    //available even when navigation is not allowed  
    [PublicStoreAllowNavigation(true)]  
    [HttpPost]  
    public ActionResult VerificationPin(string phoneNumber)  
    {  
         return Json(new {result = true, message = "Inside pin"});  
    }  

调用上述函数的Ajax代码:

var _data = { "phoneNumber": $("#Phone").val() };
                                        $.ajax({
                                            //cache: false,
                                            type:  "POST",//"GET",
                                            url: '@Url.Action("VerificationPin", "Customer")',
                                            dataType: "json",
                                            //data: JSON.stringify(_data),
                                            data: _data,
                                            success: function (data) {
                                                if (data.result)
                                                    alert("Enter the PIN code below.");
                                            },
                                            error: function (err) {
                                                alert(data.message);
                                            }
                                        });

【问题讨论】:

  • 您当前的代码正在尝试 POST ajax 请求,但您的操作方法未使用 Httppost 装饰!
  • 500 internal server error 表示正在抛出异常(如果未找到该操作,您将收到 404 Not Found)
  • @Shyju 我在注释中提到我已经尝试了所有评论。上面的 JS 代码用于“post”,然后我也使用了“get”。当我在方法之间切换时,我相应地更新了服务器代码。两者都不起作用。
  • 您检查过 nopCommerce 事件日志吗?
  • @MarcoRegueira:据我所知,nopcomemrce 无法直接处理,如果用户没有添加代码以添加登录自定义代码

标签: jquery asp.net asp.net-mvc nopcommerce


【解决方案1】:

这是我得到的解决方案

    [NopHttpsRequirement(SslRequirement.Yes)]
    //available even when navigation is not allowed  
    [PublicStoreAllowNavigation(true)]
    [HttpPost, ActionName("VerificationPin")]
    public ActionResult VerificationPin(string phoneNumber)
    {
        return Json(new { result = true, message = "Inside pin" });
    }

一个ajax

        var postData = { phoneNumber: "01683715481" }

        $.ajax({
            type: "POST",
            url: '@Url.Action("VerificationPin", "Customer")',
            data: postData,
            success: function (data) {
                if (data.result)
                    alert("Enter the PIN code below.");
            },
            error: function (err) {
                alert(data.message);
            }
        });

【讨论】:

  • 这个也不行,我试过了,还是一样的问题。 :(
  • 好的。您是否尝试删除 [NopHttpsRequirement(SslRequirement.Yes)] //即使在不允许导航时也可用 [PublicStoreAllowNavigation(true)] [HttpPost, ActionName("VerificationPin")]
猜你喜欢
  • 2018-08-01
  • 2021-02-18
  • 2020-08-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-14
  • 1970-01-01
相关资源
最近更新 更多