【发布时间】:2011-02-10 17:30:48
【问题描述】:
谁能指出我如何在 MVC 应用程序中使用带有 Facebook C# SDK 的表单帖子?这是一个基于 iframe 的 Canvas 应用程序。
我有以下代码
[HttpPost, CanvasAuthorize(Permissions = "publish_stream")]
public ActionResult Enter(FormCollection col)
{
var fbApp = new FacebookClient(this.CurrentSession.AccessToken);
JsonObject result = (JsonObject)fbApp.Get("me");
long FacebookId = long.Parse(result["id"].ToString());
//CODE TO INSERT GOES HERE
return View();
}
表格是这样的
<form action="/EnterComp/Enter" enctype="multipart/form-data" method="post">
<fieldset>
<legend>Fields</legend>
<div class="editor-label">
<label for="Text">Text</label>
</div>
<div class="editor-field">
<input id="Text" name="Text" type="text" value="" />
</div>
<div class="editor-label">
<label for="ImagePath">ImagePath</label>
</div>
<div class="editor-field">
<input type="file" name="ImagePath" id="ImagePath">
</div>
<div class="editor-label">
<label for="VideoPath">VideoPath</label>
</div>
<div class="editor-field">
<input type="file" name="VideoPath" id="VideoPath">
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
</form>
但每次我提交表单时,它似乎都会重新进行身份验证 - 因此会丢失表单集合。现在我确定我缺少一些非常简单的东西,任何帮助将不胜感激。
编辑
我想我已经在这里回答了我自己的问题,但以防我之后的其他人看到。至少对我来说,解决方案是here。
但是,如果有人可以提出其他建议。请帮忙!
【问题讨论】:
标签: c# facebook facebook-c#-sdk