Click here to Skip to main content
15,891,002 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
i have created a web form to display a pdf file in web

C#
string phy_path = FileUpload1.PostedFile.FileName;// to get full file path
 string path = MapPathReverse(phy_path);
 Session["path"] = path.ToString();
 PDF_frame.Attributes.Add("src", path);


this in code code behind

and this code in design

ASP.NET
<iframe id="PDF_frame"  runat="server"  title="document view" 
            type="application/pdf" align="bottom" > </iframe>  


but when i run this code , display this in the frame

Server Error in '/Ajax' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /Ajax/~/OLE+Automation+English.pdf

Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433


what can i do ??
Posted

1 solution

/Ajax/~/OLE+Automation+English.pdf
You can see for yourself that the path expected does not look like correctly formed. (It has tilda in between a path string)

It is a relative path issue. There is a method exposed to handle URL's. Have a read: ResolveUrl[^].

I would suggest you to use this Tip and resolve the path correctly before setting the control/image source: Resolving Paths in a Multi-Folder WebSite[^]

Doing something like this can also help: ResolveUrl(path);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900