无法保存使用ASP.NET C#Web窗体收到的Webhook数据

时间:2018-07-27 04:43:13

标签: c# visual-studio-2012 webforms webhooks asp.net-webhooks

我正在尝试构建JSON Webhook,已经配置了接收器和Webhook处理程序。我正在尝试将从Webhook接收的POST数据保存到我的SQL Server。但是我无法。

当我向Webhook URL发出HTTP请求时,我有200 OK响应,并且Webhook处理程序中的调试点从未命中。我无法解决问题,请帮帮我。

下面是我的Webhook处理程序和接收器配置以及Global.ascx

WEBHOOK处理程序

const OptimizeCssAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
require('babel-register');
module.exports = {
    entry: './src/js/app.js',
    output: {
        path: __dirname + "/src/js/",
        filename: 'app.bundle.js'
    },
    mode: 'development',
    optimization: {
        minimizer: [
            new UglifyJsPlugin({
                cache: true,
                parallel: true,
                extractComments: true
            }),
            new OptimizeCssAssetsPlugin({}),
            new CompressionPlugin()
        ]
    },
    module: {
        rules: [
            {
                test: /\.scss$/,
                use: [
                    {loader: "style-loader"},
                    {
                        loader: 'css-loader',
                        options: {
                            modules: true,
                            importLoaders: 1,
                            localIdentName: 'ko_[sha1:hash:hex:3]'
                        }
                    },
                    {
                        loader: "sass-loader"
                    }
                ]
            },
            {
                test: /\.jsx?$/,       
                exclude: /node_modules/,
                loader: "babel-loader",
                query: {
                    presets: ['react', 'es2015']
                }
            },
            {
                test: /\.js?$/,         
                exclude: /node_modules/,
                loader: "babel-loader",
                query: {
                    presets: ['react', 'es2015']
                }
            }
        ]
    },
};

RECEIVER

public CustomWebHookHandler()
{
    this.Receiver = "genericjson";
}

public override Task ExecuteAsync(string generator, WebHookHandlerContext context)
{
    //CustomNotifications notifications = context.GetDataOrDefault<CustomNotifications>();
    //return Task.FromResult(true);
    JObject dataJObject = context.GetDataOrDefault<JObject>();
    Console.Write("Data rx from webhook  " + dataJObject.ToString()); 
    return Task.FromResult(false);
}

Global.ascx

    public static class WebApiConfig
{
    public static void Register(HttpConfiguration config)
    {


        var controllerType = typeof(WebHookReceiversController);


        config.MapHttpAttributeRoutes();

        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
        config.InitializeReceiveGenericJsonWebHooks(); 
    }
}

调试点从未到达Webhook处理程序方法ExecuteAsync,我试图将数据保存到文件或数据库中。我对此很陌生,如果有人有一个想法,请帮助我。谢谢

当我向Webhook URL发出HTTP POST请求时,我在Visual Studio上注意到以下内容: iisexpress.exe Information: 0 : Registered 'IWebHookReceiver' instances with the following names: genericjson, custom. iisexpress.exe Information: 0 : Processing incoming WebHook request with receiver 'genericjson' and id 'i'. iisexpress.exe Information: 0 : Registered configuration setting 'GenericJson' for ID 'i''. iisexpress.exe Information: 0 : Registered configuration setting 'GenericJson' for ID 'z''. 'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Numerics\v4.0_4.0.0.0__b77a5c561934e089\System.Numerics.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. The thread '' (0x376c) has exited with code 0 (0x0).

0 个答案:

没有答案