Page 1 of 1

Server.MapPath() Through Image1_BeforePrint Event !

Posted: Sun Dec 06, 2009 1:01 pm
by alharbi
hi;

we can not retrieve our web application Path via Server.MapPath Function
the error message below
c:\Documents and Settings\User\Local Settings\Temp\xlrhh4iy.0.cs(29,13) : error CS0103: The name 'Server' does not exist in the current context.

we try this code
HttpContext.Current.Server.MapPath , but the error still occur .

how we can get the Path ?

thank you.

Server.MapPath() Through Image1_BeforePrint Event !

Posted: Mon Dec 07, 2009 6:05 am
by Edward
Hi

Report is being rendered not in the context of the Server request, so you need to obtain the path in advance before rendering.

Please show all the code.

You can call this method when a request is in progress so you will access to Server using

HttpContext.Current.Server

otherwise such things as Request, Response, Session and Server just inaccessible.

So make sure that the code is executed when a request is in progress, or you will be able to use the absolute path only.

Thank you.

Server.MapPath() Through Image1_BeforePrint Event !

Posted: Mon Dec 07, 2009 6:31 am
by alharbi
hi

this is our code

Code: Select all

        public void Image1_BeforePrint(object sender, System.EventArgs e)
        {
            string sPath=Server.MapPath("~//img");
            string sFile=Notif.ManagementID+".jpg";
            string sFullPath=sPath+sFile;
            Image1.Image = Image.FromFile(sFullPath);;
        }
we currently using absolute Path

Code: Select all

        public void Image1_BeforePrint(object sender, System.EventArgs e)
        {
            string sFile=Notif.ManagementID+".jpg";
            string sFullPath="d:\\www\\sahara\\hsystem\\hrmesystem.com\\www\\img\\"+sFile;
            Image1.Image = Image.FromFile(sFullPath);;
        }
we have more than one customer in deferent server , for that we must not using absolute path .

thank you.

Server.MapPath() Through Image1_BeforePrint Event !

Posted: Mon Dec 07, 2009 7:02 am
by Edward
Hi

In that case you need to obtain the path before rendering of the report and to pass this path to the report as parameter.

Thank you.

Server.MapPath() Through Image1_BeforePrint Event !

Posted: Mon Dec 07, 2009 9:22 am
by alharbi
hi

we are using report variable to pass the path to our reports now .

it be usefull if you Add Variable "AbsolutePath" to Stimulsoft Report System Variables .

thank you.

Server.MapPath() Through Image1_BeforePrint Event !

Posted: Tue Dec 08, 2009 9:04 am
by Edward
Hi

We will think about adding of this feature.

Thank you.