When running ASPNET Core application in Ubuntu 16.04 how can I access a file in another folder?

前端 未结 2 1797
南方客
南方客 2020-12-20 04:56

I am trying to run an ASP5/MVC6 ASPNET core application in Ubuntu 16.04 using dotnet core 1.1. My application resides in one directory off of the users home directory, and

相关标签:
2条回答
  • 2020-12-20 05:39

    By default static files should be located in the wwwroot folder, which inside you working folder. But if you want to keep them outside you can configure the static files middleware:

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        app.UseStaticFiles();
    
        app.UseStaticFiles(new StaticFileOptions()
        {
            FileProvider = new PhysicalFileProvider(
                Path.Combine(Directory.GetCurrentDirectory(), @"MyStaticFiles")),
            RequestPath = new PathString("/StaticFiles")
        });
    }
    

    See tutorial here.

    0 讨论(0)
  • 2020-12-20 05:51

    you can use 'ln' to Make a Link to '/home/myuser/myimages' in your working directory

    then you can reference files in your working directory

    0 讨论(0)
提交回复
热议问题