Ok well firstly if your method doesn't return a value it should be set as void eg
public void GetImageUrl(string providerUserID)
{
try
{
var user = User.GetUserFromId(long.Parse(providerUserID));
if (user != null)
{
return user.ProfileImageUrl;
}
}
catch (Exception ex)
{
}
}
}-
Is the code to return the providerUserID functioning correctly? (Does it return a valid ID everytime?)
-
You could also try Convert.ToInt64() instead of long.Parse() - I believe they both return the same though so It may not matter.
-
The only reason I can think of what with what I've seen of your code is when you refresh the page the variable providerUserID is being unset on refresh.