Nevron .NET Vision
Framework / Web Forms / Temporary Files

In This Topic
    Temporary Files
    In This Topic

    Nevron web controls can create two types of temporary files: temporary state files and temporary image files. Temporary state files are created when the control is instructed to store its state between postbacks on the hard disk. Temporary image files are generated, when the ImageAcquisitionModeproperty of the control is set to TempFile. Temporary image files can be used only when AJAX is disabled (i.e. the AjaxEnabled property of the Nevron web controls is set to false). Otherwise the value of the ImageAcquisitionModeproperty is ignored and HTTPHandleris assumed. 

    Although using an HTTPhandleris the more optimal way to render the chart/diagram image, this approach involves session state and therefore is not suitable for scenarios, when session state is not always available, like in Share Point parts (the session state is disabled by default). In such cases either temporary image files or direct image streaming to the browser must be considered as an alternative. 

    Both Nevron Chart and Diagram for .NET have built-in temporary file management, which can also be configured at runtime by modifying the properties of the NTemporaryFileSettings object, available through the ServerSettings member, available in both components:

    Copy Code
    NTemporaryFileSettings temporaryFileSettings = chartControl.ServerSettings.TemporaryFileSettings;
    Visual Basic
    Copy Code
    Dim temporaryFileSettings As NTemporaryFileSettings = chartControl.ServerSettings.TemporaryFileSettings

    By default all temporary files are stored in the NevronTemp directory located under the wwwroot of the web server executing the control. This directory must have appropriate permissions, in order for the executing component to be able to create and delete files. Since the components are operating under the ASPNET user account, it must have read, write, list folder contents and modify permissions. The latter two are required if you want automatic deletion of the expired temporary files.

    You can change the temporary directory at runtime by modifying the VirtualTempDirectory property of the NTemporaryFileSettings object, provided that the new temporary directory has the necessary permissions (otherwise an Access denied exception will be generated):

    Copy Code
    temporaryFileSettings.VirtualTempDirectory = "/SomeOtherTempDirectory";
    Visual Basic
    Copy Code
    temporaryFileSettings.VirtualTempDirectory = "/SomeOtherTempDirectory"

    Note that the temporary directory is specified by its HTTP path relative to the server root. This allows you to use virtual directories that physically reside under directories that are not direct subfolders of wwwroot. For more information on virtual directories, please consult the IIS documentation.

     Temporary File Names

    The temporary files created by the control follow a predefined naming convention. It is: 

    [Prefix][GUID].[file format]


    - [Prefix] is the value of the FileNamePrefix string property of the NTemporaryFileSettings object. The default value of this property is "NChart_" (or "NDiagram_" respectively).

    - [file format] – can be either a state file extension (nsv) or an image file extension, which depends on the image format and can be gif, png, jpg, tif, bmp, svg or svgz.

    The file name would look like:


    You can also always change the prefix at runtime:

    Copy Code
    temporaryFileSettings.FileNamePrefix = "MyChart_";
    Visual Basic
    Copy Code
    temporaryFileSettings.FileNamePrefix = "MyChart_"
     Creating The Temp Directory

    The Nevron components use a temporary directory for generating and saving images and state files for the ASP.NET Forms. Note that, when you use direct image stream to browser and no file state persistency, you do not have to create such directory, because no image content or serialized state will be stored on the hard drive. 

    The following steps should be followed to create such a temp directory:


    1. Create a folder named NevronTemp directly under your application root. For example if your application is located at "C:\Inetpub\wwwroot\WebApplication1\" this folder path must be "C:\Inetpub\wwwroot\WebApplication1\NevronTemp".
    2. Right Click on the folder and select Properties.
    3. Select the Security tab. If such is not present follow these steps to display it:

      1. Open MyComputer.
      2. Select the "Tools->Folder Options" command from the menu.
      3. Select the "View" tab in the opened dialog.
      4. Locate the "Use simple file sharing" check in the "Advanced Settings" list and uncheck it.
      5. Click "OK".
    4. Click Add, select the ASPNET user account and then click OK.
    5. Check the Write, Read, List folder contents and Read and Execute checkboxes.
    6. Apply settings and press OK
    See Also