Fixes the avatar Url from the menu

This commit is contained in:
Paul Schneider 2015-10-10 13:39:33 +02:00
commit e540aed51c
3 changed files with 17 additions and 25 deletions

View file

@ -24,7 +24,7 @@ namespace Yavsc.Controllers
/// </summary>
public class AccountController : Controller
{
string avatarDir = "~/avatars";
string defaultAvatar;
string defaultAvatarMimetype;
@ -37,20 +37,7 @@ namespace Yavsc.Controllers
[AcceptVerbs (HttpVerbs.Get)]
public ActionResult Avatar (string id)
{
if (id == null)
return new EmptyResult ();
ProfileBase pr = ProfileBase.Create (id);
var avpath = pr.GetPropertyValue("Avatar");
if (avpath == null) {
FileInfo fia = new FileInfo (Server.MapPath (defaultAvatar));
return File (fia.OpenRead (), defaultAvatarMimetype);
}
string avatarLocation = avpath as string;
if (avatarLocation.StartsWith ("~/")) {
avatarLocation = Server.MapPath (avatarLocation);
}
string avatarLocation = Url.AvatarUrl (id);
WebRequest wr = WebRequest.Create (avatarLocation);
FileContentResult res;
using (WebResponse resp = wr.GetResponse ()) {