c# - Access to the path is denied ... Why? -


been having asp.net issues morning, , got new one, this

string filepath = ""; filepath = server.mappath(request.querystring["filedownloadable"]); if (filepath != null) {     response.clear();     response.addheader("content-disposition", "attachment; filename=mypdf.pdf");     response.writefile(filepath);     response.contenttype = "";     response.end(); } 

gives me error on line 18 response.writefile(filepath); , says access path denied....why doing this?

the request.querystring["filedownloadable"] comes code...

<li><a href="./downloadableproducts.aspx?filedownloadable=/downloadableproducts/mypdf.pdf" runat="server">ipc client personal financial website feb 12</a></li>

i checked permissions on folder , have same kind of permissions has every other folder in root.

any suggestions please?

i ran code inbetween code behind see if file exist..

if(file.exists(filepath)){ } 

and ran page without error no functionally of page wasnt working, tells me filepath not exist.

access path being denied because doesn't exist. before blasting file out response.writefile should perform @ least check see if file exists first. give opportunity of making sure path it's attempting work.

also keep in mind it's not going aware of "relative" path you're working on within scope of web application. should make sure use either server.mappath or configuration setting ensure filepath variable looks absolute path on os such e:\inetpub\wwwroot\....


Comments