Search code examples
asp.netasp.net-corelogfilewebclient

Cannot download log files through `WebClient.DownloadFile` method in ASP.NET Core


I am using WebClient.DownloadFile() method for downloading files through my Localhost URL. And it is working well for all files except for log files. When I download log files it shows contents as "Not Authorized" Also it occurred to me than when I open log files in browser through URL then it won't show its contents in browser as "Not Authorized"

Is there a way to access contents of log file through WebClient.DownloadFile() method.

I want to download these files with its content into the specified location.


Solution

  • Try saving your log in .txt format.

    I faced similar problem once. Then I updated code which generates the .log files. And change the file extension to .txt which means the files which will be generated will be of .txt format and not .log format.

    Generating .txt files for log will be helpful for downloading it via specified method.