You are right that currently only RPC calls have CSRF protection, and that the idiomatic way to send form data is therefore to use RPC.

Adding CSRF protection to sitelets is on our TODO list. This issue aside, you can do classic form submission using sitelets and FormData:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
type EndPoint =
    // ...
    | [<EndPoint "POST /post">] Posted of args: PostedArgs

and PostedArgs =
    {
        [<FormData>] x: int
        [<FormData>] y: string
    }

[<Website>]
let MyWebsite =
    Application.MultiPage (fun ctx ep ->
        match ep with
        | Posted args -> // args.x and args.y come from the form submit
    )
1
2
3
4
5
<form action="/post" method="post">
  <input name="x" type="number" />
  <input name="y" />
  <input type="submit" />
</form>
By on 10/26/2016 8:44 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper