Manish Chitre
Manish Chitre

Reputation: 121

custom form with method="POST" isn't getting displayed in task module ms teams

I am unable to to get a custom form to display in Task Module. It's a form with few input elements and method="POST" attribute. When I remove "method" attribute the task module displays custom form correctly. I just want to post input field values to controller.

PS: Everything works when I run those forms in browser. I have also added valid domains in teams and task module renders perfectly without method="POST" attribute in form tag.

enter image description here

This is my .cshtml page with form method. enter image description here

Here is Controller class

 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();
    }
}

Upvotes: 0

Views: 131

Answers (1)

Abhijit
Abhijit

Reputation: 541

I missed to respond here. Your back end code has no issues. On frontend, you need to submit your frontend input values to "microsoftTeams.tasks.submitTask(youJSObject)" in js object and same thing you can receive in turnContext of the "OnTeamsTaskModulesSubmitAsync" method.

Upvotes: 1

Related Questions