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 2424 <td >Name </td >
2525 <td >@user.DisplayName </td >
2626 </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 >
4327 </table >
4428}
4529
4630@code {
4731 User user ;
48- string photo ;
4932
5033 protected override async Task OnInitializedAsync ()
5134 {
5235 try
5336 {
5437 user = await GraphServiceClient .Me .Request ().GetAsync ();
55- photo = await GetPhoto ();
5638 }
5739 catch (Exception ex )
5840 {
5941 ConsentHandler .HandleException (ex );
6042 }
6143 }
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-
8444}
You can’t perform that action at this time.
0 commit comments