Server.MapPath() Through Image1_BeforePrint Event !

Stimulsoft Reports.NET discussion
Post Reply
alharbi
Posts: 45
Joined: Wed Sep 05, 2007 1:56 pm
Location: KSA

Server.MapPath() Through Image1_BeforePrint Event !

Post 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.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Server.MapPath() Through Image1_BeforePrint Event !

Post 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.
alharbi
Posts: 45
Joined: Wed Sep 05, 2007 1:56 pm
Location: KSA

Server.MapPath() Through Image1_BeforePrint Event !

Post 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.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Server.MapPath() Through Image1_BeforePrint Event !

Post 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.
alharbi
Posts: 45
Joined: Wed Sep 05, 2007 1:56 pm
Location: KSA

Server.MapPath() Through Image1_BeforePrint Event !

Post 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.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Server.MapPath() Through Image1_BeforePrint Event !

Post by Edward »

Hi

We will think about adding of this feature.

Thank you.
Post Reply