Form and Request.Form in a asp.net MVC3 Facebook Application
I'm working on a facebook app and facing a problem with my forms with MVC3 with Razor.
A. Working form:
index.cshtml
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
@Html.TextBox("tbTest", "Pouet pouet", new { Width = "500px" })
<input type="submit" name="btnCalculate">calculer vos tarifs</input>
} Result form : @Request.Form <br />
HomeController.cs:
public ActionResult Index()
{
return View();
}
B. Bugging form :
About.cshtml :
@using (Html.BeginForm("About", "Home", FormMethod.Post))
{
@Html.TextBox("tbTest", "Pouet pouet", new { Width = "500px" })
<input type="submit" name="btnCalculate">calculer vos tarifs&l开发者_运维百科t;/input>
} Result form : @Request.Form <br />
HomeController.cs :
[CanvasAuthorize(Permissions = "user_about_me,manage_pages,offline_access")]
public ActionResult About()
{
var fb = new FacebookWebClient();
FacebookWebClient fbApi = new FacebookWebClient(FacebookWebContext.Current.AccessToken);
dynamic result = fb.Get("me");
return View();
}
In apps.facebook.com/appname/home/index, the form is working, Request.Form return tbTest = Pouet pouet. In apps.facebook.com/appname/home/about, the form return nothing else but Signed_Request.
EDIT If I edit HomeController.cs like this
[CanvasAuthorize(Permissions = "user_about_me,manage_pages,offline_access")]
public ActionResult Index()
{
the first page, index.cshtml, does not work anymore... The post only return Signed_Request.
So, I think I have a problem using Facebook SDK and Signed request, no ? Could you help me please. Why does the form is not sent or lost in the About page ?
for post backs you need to maintain the signed request manually.
http://facebook.stackoverflow.com/a/5364815/157260
Because you have
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
in your About form, which causes it to POST to Index instead of About. Change it to
@using (Html.BeginForm("About", "Home", FormMethod.Post))
精彩评论