我无法获取自定义表格以显示在任务模块中。这是一种很少有输入元素和method =“ POST”属性的表单。当我删除“方法”属性时,任务模块会正确显示自定义表单。 我只想将输入字段值发布到控制器。
PS:当我在浏览器中运行这些表单时,一切正常。我还在团队中添加了有效域,并且任务模块完美地呈现了表单标签中没有method =“ POST”属性的情况。
这是控制器类
public class HomeController : Controller
{
public SuspectRegistration registration;
public HomeController()
{
registration = new SuspectRegistration();
}
// GET: /<controller>/
public IActionResult Index()
{
return View();
}
public IActionResult CustomForm()
{
return View();
}
public IActionResult PRFPDetailsForm()
{
return View();
}
// This is the method where I need to get values, it works in browser without any issues.
[HttpPost]
public IActionResult PRFPDetailsForm(SuspectRegistration formData)
{
HttpContext.Session.SetString("formdata", JsonConvert.SerializeObject(formData));
return View("PRFPDetailsForm");
}
public IActionResult PRFPRegistrationConfirmation()
{
var value = HttpContext.Session.GetString("formdata");
var suspectRegistration = JsonConvert.DeserializeObject<SuspectRegistration>(value);
ViewBag.SuspectRegistration = suspectRegistration;
return View();
}
}
答案 0 :(得分:1)
我错过了在这里回复的机会。您的后端代码没有问题。在前端,您需要将前端输入值提交到js对象中的“ microsoftTeams.tasks.submitTask(youJSObject)”,并且可以在“ OnTeamsTaskModulesSubmitAsync”方法的turnContext中接收相同的内容。