0

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?

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by murugavel84
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.