locked
How to download file from asp .Net website which has read-only access? RRS feed

  • Question

  • User1272818216 posted
    I have a file present on server. The file on server is read-only. When I download the file from ASP .NET application to my local machine, the file has read and write access both. The original read-only attribute removed. I want to download the file read-only mode. Could you please suggest the proper solution for this problem
    Friday, March 2, 2018 2:26 PM

All replies

  • User475983607 posted

    Read/Write is a property of the file system not the file and web app cannot affect the file system. 

    If this is a Word file then you can protect the file with Word.

    https://support.office.com/en-us/article/make-a-document-read-only-5c25909c-46d9-4eb0-9d1f-d072a560e340?ui=en-US&rs=en-US&ad=US

    If this is a text file then you are out of luck.   Rather than downloading the file you'll need to provide the file contents in a web page.

    Friday, March 2, 2018 2:45 PM
  • User1272818216 posted
    I am generating Excel file using Microsoft interop components. Is their any mechanism while creating the excel we can make this read-only worksheet in c#.
    Friday, March 2, 2018 2:48 PM
  • User475983607 posted

    londhess

    I am generating Excel file using Microsoft interop components. Is their any mechanism while creating the excel we can make this read-only worksheet in c#.

    Office Interop should work since Excel also has the read-only feature (MS Office).  You'll need to search through the Interop docs to find the API or ask this question on the MS Office support forum.  This is an ASP.NET support forum.

    However, I must warn you that Office Interop on a web server is not recommended or supported by Microsoft.  The reason is MS Office must be installed on the server, which is a security risk, and Interop actually opens Excel to perform the operations.  This can cause concurrency issues.

    I suggest that you create a PDF which is, for the most part, read only.

    Friday, March 2, 2018 4:13 PM