我正在建立一个论坛,人们可以在其中发表两种类型的帖子。如何让我的“回复”页面根据发送的参数来响应POST请求?
我尝试使每个函数具有不同的参数,但没有区别。我叫他们的唯一方法是将它们都命名为OnPost
。现在它给了我这个错误:
System.InvalidOperationException: Multiple handlers matched. The following handlers matched route data and had all constraints satisfied:
自从我发送(int, string, string, string)
以来,没有意义,而处理程序是:
OnPost(Int32, System.String, System.String, System.String)
OnPost(Int32, Int32, System.String, System.String, System.String)
答案 0 :(得分:0)
我只是在回复页面的顶部做了// WITH WEBHOOK-GENERATED IDS
const data = "Something you want to save";
let userId;
// if a value for userID exists in user storage, it's a returning user so we can
// just read the value and use it. If a value for userId does not exist in user storage,
// it's a new user, so we need to generate a new ID and save it in user storage.
if ('userId' in conv.user.storage) {
userId = conv.user.storage.userId;
} else {
// generateUUID is your function to generate ids.
userId = generateUUID();
conv.user.storage.userId = userId
}
saveDataToDB(userId, data);
,将每个处理程序重命名为@page "{handler?}"
,其中Handler是任何其他名称,并将表单操作设为OnPostHandler
答案 1 :(得分:0)
我认为您不应有两个同名的发布方法。您可以重命名其中之一,然后使用javascript发出自定义请求。