喜的朋友我试图用这种方式张贴在墙上的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