Question

I have a "ticket system" and when the user creates a ticket there is an option to upload files. Those files go to a folder that have the name of the ticket.

This is the code that creates the folder when the ticket is created.

 var nomePasta = "Ticket Id - " + idNovoPedido;
                 string salva =   Path.Combine(Server.MapPath("~/"),"uploadedFiles",nomePasta);
                 Directory.CreateDirectory(salva);

Then on the backoffice i can see if there are any files on that folder.

Code to check if there are any files:

@foreach (string fullFilePath in Directory.GetFiles(Path.Combine(Server.MapPath("~/uploadedFiles"),"Ticket Id - "+@id)))
                    {
                        <div class="linkFicheiros">
                            <a href="@Href("~/uploadedFiles","Ticket Id - "+@id,Path.GetFileName(fullFilePath))">@Path.GetFileName(fullFilePath)</a>
                        </div>
                    }

Now my question is, how can i download the files?

If i click on a link (example if it's a photo, my browser opens a new window and show me the image) and if it's a "docx" it says that "The page cannot be found."

Update:

So i've found something, if the file is ".xls" i can download it without any problem, but if the file is ".docx" it gives the error mentioned above "The page cannot be found.".

Any thoughts ?

Was it helpful?

Solution

There are other warnings in Internet for the same problem stating that it depends on the lack of definition on the web server for the DocX files' MIME type : Page cannot be found Error when executing a Hyperlink to a DocX File.

Anyway, if it could be useful, in this article I have used a universal routine for the file downloading: Downloading Files C#. You should add the .docx case and its MIME type:

application/vnd.openxmlformats-officedocument.wordprocessingml.document

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top