0

I am trying to read and display a file using MapPath as follows :

    Response.ContentType = "Application/pdf"
    Dim FilePath As String = MapPath("../Document/123.pdf")
    Response.WriteFile(FilePath)
    Response.End()

This procedure will work fine and display in the browser. However, if I save the file to C:\Document\123.pdf, how can I access this file using relative path in MapPath function. Is there an option to access the file which is saved out of IIS server? I am using vb.net 2003.

1 Answer 1

1

If you want to access a file outside the web site, you don't use MapPath. Just use the absolute path directly:

Dim FilePath As String = "C:\Document\123.pdf";
Sign up to request clarification or add additional context in comments.

2 Comments

Yes, I tried with absolute path and it's working fine. Thank you.
May I know the best practice to display the PDF file in the browser ?

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.