c# - WebForms 相当于 MVC 的 "return Content()"?

标签 c# asp.net asp.net-mvc webforms braintree

我正在尝试验证 Braintree's webhook notifications 的端点。他们向我发送了一个 GET 请求,其中包含一个我需要在其函数之一中使用的参数。

我想我应该发回一个 POST 请求,但不确定正确的实现。相当于 MVC 的 return Content() 的 Web 表单是什么?

public class WebhooksController : Controller
{
  public ActionResult Accept()
  {
    return Content(Constants.Gateway.WebhookNotification.Verify(Request.QueryString["bt_challenge"]));
  }
}

最佳答案

不确定这是否是最好的方法,但你可以制作 generic handler .

public class MyHandler : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        // here you have access to context.Request and context.Response
    }

    public bool IsReusable
    {
        get { return false; }
    }
}

关于c# - WebForms 相当于 MVC 的 "return Content()"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24977322/

相关文章:

c# - 在动态方法中使用正则表达式

具有相对路径的 Asp.net 自托管 WCF 服务 WSDL

c# - 为什么 MVC HttpPostedFileBase 总是空的?

c# - 将表而不是范围定义为数据透视表 'cacheSource'

c# - 通过合并两个列表创建一个列表

asp.net - 使用代理ASP.NET更改YouTube URL

asp.net-mvc - 种子 MVC5 Entity Framework 6 中的无效登录尝试

javascript - 如何将 json 对象发送到 Controller JsonResult 方法

c# - 从查询创建 DataTable 的最快方法?

c# - 如何从 Dotnet EF 中删除唯一索引?