0

I have written a piece of code for downloading the file from the server. So when I download it, the file gets downloaded properly. But when I Open the document, it shows me error as.

Failed to load particular document.

Also while debugging I get error as.

'https:/NVMBD1BKH150V02.IN.RIL.COM/MWSiteSurveyDoc/I-KA-ANKL-ENB-0012_C2/180.jpg' is not a valid virtual path.

when I open the URL in browser, the file is opened properly.

Here is my code below

protected void lnkDownload_Click(object sender, EventArgs e)
{
    try
    {
        string FulfilePath = (sender as LinkButton).CommandArgument;
        string[] filePath = FulfilePath.Split('\\');               
        string path = @"" + ConfigurationManager.AppSettings["NASSServerPath_MW_Feasibility_Download"].ToString() + "/" + filePath[7] + "/" + filePath[8];
        // Response.ContentType = ContentType;                               

        Response.ContentType = ContentType;
        Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(path));
        Response.TransmitFile(path);
        Response.End();

    }
    catch (Exception ex)
    {
        // objCom.ErrorLog(ex.GetType().ToString(), ex.Message, "Download Files", Session["UserName"].ToString());
    }

}

1 Answer 1

1

HttpResponse.Transmit takes a server physical path to a file as a parameter. Seems you are trying to pass a remote URI instead, and there is also a typo: a slash is missing in http:// prefix.

You either need to provide a local path to the TransmitFile method or redirect the request to the URI

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.