[RESOLVED]How To Download file from server


I have one link in my page when i click that link the file has to be downloaded from server or playstore.but i don’t know that code can any please tell me that and solve my problem.

any code is required for that or just path address of that file is enough.??




just path address of that file is enough

In most scenarios just the address of the file is enough.

What is the file extension

Hi Prasanna ,

what ever it may be (exe,apk,png…etc).. it is also enough for that path..

in local it is woking ,when by global also it works or not..


Hi praveen,

To download the file, we could use FileResult as the return type.

For example:

public FileResult Download()
    byte[] fileBytes = System.IO.File.ReadAllBytes("c:foldermyfile.ext");
    string fileName = "myfile.ext";
    return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);

We also could base on file path to return the file.

Best Regards


Hi Starain,

Thanks for the reply.Right now I’m using HTML tag in my asp.net mvc project to download the file…i.e..

<a href="~/Content/Images/Main_Logo-01.png" download="Main logo">com.IceCreamSandwich.android.4.0-4.0.2</a>

 It works properly in my local system …is it works when i host  my project in server or not…???



Hi friends,

I check that code in server it works good..and the issue is when i put the
file instead of that png or pdf .

it is not downloading the apk file from server and also from my project (visual studio).. can u guys please fix this issue..how to do this thing i dont’ve any idea about that..



Hi Praveen,

You need to add a new MIME type with apk file name extension.

More information, please refer to:

# Add a MIME Type (IIS 7)


Best Regards



by adding the below line in webconfig file i got solve the problem ..


<mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive" />



Thank You guys for the support…



Leave a Reply