hi, i have an aspx page, Default.aspx, which runs when a web service is called.

the output of the web service is something like this:

http:\\xx.xx.xxx.xxx\FileDownload\Default.aspx?download=2.csv&type=csv

This link above will download the csv file present on the server.

The code for the default.aspx is given below. I want to know how to add a class to this web application so that i can get the 'path' by calling a class PathResolver.cs where the path is hard-coded. I want all the paths to be present at one place and hence this .cs file. how can i achieve this?

<html xmlns="http://www.w3.org/1999/xhtml" >


<head runat="server">
    <title>Untitled Page</title>
    <script runat="server" language="C#">
        private void Page_Load(object sender, System.EventArgs e)
        {
            string file = Request.Params.Get("download");
            string path = "c:/temp/";

            //string path = PathResolver.getPathForParam();
//getPathForParam() will return the correct path which is hard-coded in PathResolver.cs

            Response.AddHeader("Content-disposition", "attachment; filename=" +file);
            
            string type = Request.Params.Get("type");
            if(type.Equals("png"))
            Response.ContentType = "image/png";
            else if (type.Equals("csv"))
            Response.ContentType = "text/csv";
        else if (type.Equals("txt"))
            Response.ContentType = "text/txt";
        else
            Response.ContentType = "application/octet-stream";

            Response.WriteFile(path+file);
        } 
        </script>
</head>
<body></body>
</html>

I am getting this error when i try to build this file at the commented lines of PathResolver.getPathForParam();

The name 'PathResolver' does not exist in the current context c:\inetpub\wwwroot\FileDownload\Default.aspx


Any Suggestions?

Create a folder named App_Code under your application root and copy PathResolver.cs in it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.