C# Webmatrix/Razor-问题返回正文
我正在尝试为webhook响应编写一个快速页面。该方法需要获取查询字符串参数,并在主体中传回响应。这是我到目前为止所拥有的C# Webmatrix/Razor-问题返回正文,c#,asp.net,razor,webmatrix,braintree,C#,Asp.net,Razor,Webmatrix,Braintree,我正在尝试为webhook响应编写一个快速页面。该方法需要获取查询字符串参数,并在主体中传回响应。这是我到目前为止所拥有的 @using System; @using System.Collections.Generic; @using Braintree; @using System.Diagnostics; @{ Layout = "~/template"; //Initialise Braintree Server SDK BraintreeGateway gat
@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.\u Page\u Payments\u Webhook\u 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"]);