不确定这是MVC中的最佳方法,但我如何返回条件视图,假设我想返回另一个视图,如果缺少'fbUID'则显示一些错误消息,请协助。谢谢。MVC +在条件下返回不同的部分视图
public PartialViewResult GetCredentials(string facebookUID, string facebookAccessTok)
{
string fbUID = facebookUID;
if (fbUID != null)
{
// Request fb profile pic
var rawImg = new Bitmap(ImageHelper.requestBitmapImage(fbUID));
var processblurredImg = new Bitmap(rawImg);
var gb = new GaussianBlur();
for (int i = 0; i < 8; i++)
{
gb.ApplyInPlace(processblurredImg);
}
// Download it to local drive/server
string uploadPath = Server.MapPath("~/upload");
string fullPath = uploadPath + "\\ProfilePic.png";
if (!Directory.Exists(uploadPath))
{
Directory.CreateDirectory(uploadPath);
}
if (uploadPath != null)
{
ImageHelper.savePng(fullPath, processblurredImg, 500L);
}
return PartialView("BlurredPhoto");
}
return PartialView("TestPartialView"); //if fbUID is null
}