How to browse a folder in blazor server c#

Lou, Kecheng 20 Reputation points

The blazor server app has a folder that contains pdf files, the folder has web config file, see the below

<?xml version="1.0" encoding="UTF-8"?>
        <directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension, LongDate" />

I use the following <a> html link to browse the folder, it work on form project, but does not work on blazor server project, get "Sorry, there's nothing at this address." message. this folder is in wwwroot folder.

<a href="./PDFFiles/Production">View Production Files</a>

how to resolve this issue? thanks

A set of technologies in the .NET Framework for building web applications and XML web services.
3,124 questions
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
968 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
8,160 questions
0 comments No comments
{count} votes

3 answers

Sort by: Newest
  1. Lou, Kecheng 20 Reputation points

    I did resolve it.

    use the following, instead of <a href=".\PDFFiles\Production">Production</a>

    <a href=".\wwwroot\PDFFiles\Production">Production</a>

    the PDFFile Folder is inside wwwroot folder.

    Thank you.

    0 comments No comments

  2. Bruce ( 35,416 Reputation points

    because there is no file extension, the javascript routing for blazor will try to route to a blazor page.

    you should make the pdf folder a peer, and define a folder for the blazor app

    .if you define the static file handler, you coudl use <a target="_blank ...> to bypass the javascript router.

    0 comments No comments

  3. Anderson Kovalski 21 Reputation points

    You need to enable static assets


    0 comments No comments