I have a Blazor server side app. How can I display a text file in my razor page directly in an iframe?

226 Views Asked by At

I have a Blazor server side app. Currently I am reading the file line by line and adding each line to a list. Then I am displaying each list element (line) in a table row by row in my razor file.

Is there a possiblity to display the file content directly in my razor file (for example iframe)? My text file is on the server where my app is running.

My current cs file

public void read_file_content() 
{
var lines = File.ReadLines(TagService.PLC_alarm_text_path,Encoding.GetEncoding("Windows-1254"));                   
                
   foreach (var line in lines)
   {
      TagService.PLC_alarm_text_definition.Add(line);
   }
}

My current razor file

    <table>
        @for (int f = 0; f < TagService.PLC_alarm_text_definition.Count; f++)
        {
          <tr>
              <td>@TagService.PLC_alarm_text_definition[f]</td>                    
          </tr>
        }
    </table>
0

There are 0 best solutions below