Reputation:
I am on developing a website using ASP.Net (VB.net), @ particular phase Execute the following code to
Private Sub btndownload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btndownload.Click
Response.ContentType = "application/pdf"
Response.TransmitFile(hdndownload.Value) ' http:/localhost/sample_web/sample.pdf is the value for hdndownload.Value
End Sub
But it result in error as follows:
Server Error in '/sample_web' Application.
http://localhost/sample_web/sample.pdf' is not a valid virtual path.
An unhandled exception occurred during the execution of the current web request.
Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: 'http:/localhost/sample_web/sample.pdf' is not a valid virtual path.
Upvotes: 2
Views: 3721
Reputation: 1688
If the value in your comment for hdndownload.value is correct you ars missing a /
the value being passed should be
http://localhost/sample_web/sample.pdf
^
not
http:/localhost/sample_web/sample.pdf
Upvotes: 1