File tree Expand file tree Collapse file tree 1 file changed +0
-40
lines changed
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Pages Expand file tree Collapse file tree 1 file changed +0
-40
lines changed Original file line number Diff line number Diff line change 24
24
<td >Name </td >
25
25
<td >@user.DisplayName </td >
26
26
</tr >
27
- <tr >
28
- <td >Photo </td >
29
- <td >
30
- @{
31
- if (photo != null )
32
- {
33
- < img style = " margin: 5px 0; width: 150px" src = " data:image/jpeg;base64, @photo" / >
34
- }
35
- else
36
- {
37
- <h3 >NO PHOTO </h3 >
38
- <p >Check user profile in Azure Active Directory to add a photo .</p >
39
- }
40
- }
41
- </td >
42
- </tr >
43
27
</table >
44
28
}
45
29
46
30
@code {
47
31
User user ;
48
- string photo ;
49
32
50
33
protected override async Task OnInitializedAsync ()
51
34
{
52
35
try
53
36
{
54
37
user = await GraphServiceClient .Me .Request ().GetAsync ();
55
- photo = await GetPhoto ();
56
38
}
57
39
catch (Exception ex )
58
40
{
59
41
ConsentHandler .HandleException (ex );
60
42
}
61
43
}
62
-
63
- protected async Task <string > GetPhoto ()
64
- {
65
- string photo ;
66
-
67
- try
68
- {
69
- using (var photoStream = await GraphServiceClient .Me .Photo .Content .Request ().GetAsync ())
70
- {
71
- byte [] photoByte = ((System .IO .MemoryStream )photoStream ).ToArray ();
72
- photo = Convert .ToBase64String (photoByte );
73
- this .StateHasChanged ();
74
- }
75
-
76
- }
77
- catch (Exception )
78
- {
79
- photo = null ;
80
- }
81
- return photo ;
82
- }
83
-
84
44
}
You can’t perform that action at this time.
0 commit comments