Transferring data from the controller to view mode and back to the controller

I'm trying to make an invitation system, and if my decision looks strange, even for me, something should be wrong.

User invites invitation URL

site.com/Account/Invitation/invitationGUID

public ActionResult Invitation(Guid invitationGUID)
{
    //Check for the existence of the invitation id
    if(true)
        return RedirectToAction("Account","Register")
    return View("InvalidInvite");
}

I need to pass the GUID invitation to the Register action

public ActionResult Register()
{
    //this is the registration form
    return View();
}

And I still need an invitation GUUID in the mail to save this information

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Register(string email, string password, string confirmPassword,
                                 string firstName, string lastName, string cep)
{
    //register user
    return View();
}

What should I do to convey this information?
I tried to transfer data from Invitation → Register

return RedirectToAction("Account","Register",invitationGUID)

Calling the form Register with a GUID prompt

return View("Register",invitationGUID);

And using hidden input in the registry view to get it back using POST

<%= Html.Hidden("invitationGUID",(Guid)Model %>

, , , /.
?
POST POST .
, -?

+3
3

, . , . , .

, , inviteID. , Register inviteID. .

, - , . , , , - . , ID, . .

, , - . . Register.

. - , ? ( ). :)

, . , , . , . , HTTP GET , :

site.com/Account/Register/invitationGUID

site.com/Account/Register?invite=invitationGUID

, ( ) QueryString . , , - , . , requestID, , , .

+1
return RedirectToAction("Account", "Register", new { invitation = invitationGUID });

GUID :

public ActionResult Register(Guid invitation)
{
    //this is the registration form
    return View();
}

Html.BeginForm(), :

<% using (Html.BeginForm()) { %>
...
<% } %>

GUID querystring:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Register(string email, string password, string confirmPassword,
    string firstName, string lastName, string cep, Guid invitation)
{
    //register user
    return View();
}
+1

, TempData. . .

0

Source: https://habr.com/ru/post/1711099/


All Articles