网络矩阵/剃刀-问题返回体
本文关键字:问题 返回 剃刀 网络 | 更新日期: 2023-09-27 17:49:41
我正在尝试为webhook响应编写一个快速页面。该方法需要接受查询字符串参数,并在正文中传回响应。以下是我目前所掌握的信息。
@using System;
@using System.Collections.Generic;
@using Braintree;
@using System.Diagnostics;
@{
Layout = "~/template";
//Initialise Braintree Server SDK
BraintreeGateway gateway = new BraintreeGateway
{
Environment = Braintree.Environment.SANDBOX,
PublicKey = "xxx",
PrivateKey = "xxx",
MerchantId = "xxx"
};
return gateway.WebhookNotification.Verify(Request.QueryString["bt_challenge"]);
}
问题是,当我运行这个页面时,我得到以下错误消息:
由于'ASP._Page_Payments_Webhook_cshtml.Execute()'返回void,因此return关键字不能后跟对象表达式
虽然我不熟悉你正在尝试做的所有事情,但我不相信cshtml页面应该返回任何东西,因此发出警告。因此,除了最后两行代码之外,请完全按照您已有的代码进行尝试。删除返回值,改为:
@using System;
@using System.Collections.Generic;
@using Braintree;
@using System.Diagnostics;
@{
Layout = "~/template";
//Initialise Braintree Server SDK
BraintreeGateway gateway = new BraintreeGateway
{
Environment = Braintree.Environment.SANDBOX,
PublicKey = "xxx",
PrivateKey = "xxx",
MerchantId = "xxx"
};
}
@gateway.WebhookNotification.Verify(Request.QueryString["bt_challenge"]);