喜的朋友我試圖用這種方式張貼在牆上的Facebook照片如何在Facebook牆上上傳照片?
這裏我控制代碼:
公共類測試 {
public FacebookMediaObject mediaObject { get; set; }
}
public ActionResult Profile(FacebookOAuthResult facebookoAuthResult)
{
DisplayAppropriatemessage(facebookoAuthResult);
// redirect back to the index action to show the form once again
return RedirectToAction("Profile");
}
private void DisplayAppropriatemessage(FacebookOAuthResult facebookoAuthResult)
{
if (facebookoAuthResult != null)
{
if (facebookoAuthResult.IsSuccess)
{
var mediaObject = new FacebookMediaObject
{
ContentType = "image/jpeg",
FileName = Path.GetFileName(path)
}
.SetValue(System.IO.File.ReadAllBytes(path));
var fb = new FacebookClient(facebookoAuthResult.AccessToken);
fb.PostAsync("https://graph.facebook.com/me/photos", new Dictionary<string, object> { { "source", mediaObject } });
}
}
throw new NotImplementedException();
}
這裏我profile.cshtml代碼:
@using (Html.BeginForm("Profile", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="file" id="file" /><br />
<input type="submit" value="Upload" />
}
而我運行這段代碼,當我點擊後按鈕,它給下面的錯誤
'/'應用程序中的服務器錯誤。 沒有爲此對象定義的無參數構造函數。 描述:執行當前Web請求期間發生未處理的異常。請查看堆棧跟蹤以獲取有關該錯誤的更多信息以及源代碼的位置。
異常詳細信息:System.MissingMethodException:沒有爲此對象定義的無參數構造函數。
源錯誤:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
我試圖以多種方式,但每次我我失敗
您的控制器是否有定義的構造函數? – AaronLS 2012-07-18 06:12:37
是的那些是[httppost]和[ValidateInput(false)] [AcceptVerbs(HttpVerbs.Post)] – siva 2012-07-18 06:27:39
請向我們展示堆棧跟蹤,將有助於查明您試圖調用無參數構造函數的位置 – RhysW 2012-07-18 13:09:22