Error 404 when trying to download PDF - ASP.Net C #

0

I need to download a PDF that I have stored inside a folder in my application, I want it to open in a new tab.
The following code works perfectly for me in my local application but once published on the server and trying to download the file, it throws the error:

  

'404 error file or page not found'

Code that works in my local application but not on the server:

protected void Manual_Click(object sender, EventArgs e)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('/ModuloGeneral/ImpresionConf/Manual.pdf'),'_blank')", true);
        }  

I also tried adding the ñuflo in front of the url but it does not work either:

 System.Web.UI.ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('~/ModuloGeneral/ImpresionConf/Manual.pdf'),'_blank')", true);  

and this way it does not work either:

System.Web.UI.ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('~\ModuloGeneral\ImpresionConf\Manual.pdf'),'_blank')", true);

I leave the .aspx of the LinkButton that I use to download the file:

<td colspan="7" align="center">                     
   <asp:LinkButton ID="Manual" runat="server" class="lnkDocumento" OnClick="Manual_Click">Manual</asp:LinkButton><br /><br />
</td>
    
asked by Pablo Matias 05.06.2018 в 17:07
source

1 answer

0

Finally the problem was the reading of the URL by the server, I had to use the type of literal syntax so that the path of the URL can be read.

System.Web.UI.ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", @"window.open('\ImpresionConf\Manual.pdf','_blank')", true);

I leave a link about the handling of chains in case someone serves you which is where I got the information: Strings_C # .

    
answered by 05.06.2018 / 20:31
source