Fixes the avatar Url from the menu

vnext
Paul Schneider 9 years ago
parent 424bb157e3
commit e540aed51c
3 changed files with 17 additions and 25 deletions

@ -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 ()) {

@ -151,10 +151,18 @@ namespace Yavsc.Helpers
/// <param name="helper">Helper.</param>
/// <param name="username">Username.</param>
public static string AvatarUrl (this System.Web.Mvc.UrlHelper helper, string username) {
if (username == null)
return null;
ProfileBase pr = ProfileBase.Create (username);
var a = pr.GetPropertyValue("Avatar") ;
if (a == null || a is DBNull) return "/avatars/" + helper.Encode(username)+".png";
return helper.Encode ((string)a);
object avpath = null;
if (pr != null) avpath = pr.GetPropertyValue("Avatar");
if (avpath == null) return "/bfiles/"+username+".png";
string avatarLocation = avpath as string;
if (avatarLocation.StartsWith ("~/")) {
avatarLocation = helper.RequestContext.HttpContext.Server.MapPath(avatarLocation);
}
return avatarLocation;
}
}
}

@ -80,10 +80,7 @@ $(document).ready(function(){
<asp:ContentPlaceHolder ID="overHeaderOne" runat="server">
<h1><a href="<%= Html.Encode(Request.Url.AbsoluteUri.ToString()) %>"> <%=ViewState["orgtitle"]%> </a>
<span> -
<a href="<%= Url.Content("~/") %>"><%= YavscHelpers.SiteName %></a>
</span></h1>
<h1><a href="<%= Url.Content("~/") %>"> <%=ViewState["orgtitle"]%> </a></h1>
</asp:ContentPlaceHolder>
@ -104,7 +101,7 @@ $(document).ready(function(){
</a>
<% } else { %>
<a href="/Blog/<%= HttpContext.Current.User.Identity.Name%>" accesskey = "B" class="menuitem">
<img src="<%=Html.AvatarUrl(HttpContext.Current.User.Identity.Name)%>" alt="vos billets" class="iconsmall" />
<img src="<%=Url.AvatarUrl(HttpContext.Current.User.Identity.Name)%>" alt="vos billets" class="iconsmall" />
<div class="hint">Vos billets</div>
</a>
<a href="<%= Url.Content("~/Account/Profile/" + HttpContext.Current.User.Identity.Name) %>" accesskey="L" class="menuitem">

Loading…