TreeView Control Issue..

Last post 01-22-2004 2:28 PM by Kiliman. 2 replies.

Sort Posts:

  • TreeView Control Issue..

    01-13-2004, 1:33 PM
    • Member
      5 point Member
    • kavuris
    • Member since 06-17-2002, 7:37 PM
    • Posts 1
    I am trying to use IE treeview control (newly compiled after download from www.asp.net).

    1. I copied the webctrl_client into the directory
    2. copied the Microsoft.Web.UI.WebControls.dll into the bin directory.
    3. Had a page referring to treeview control (from sample from msdn website)
    4. started cassini webserver (port 80)

    the directory structure looks like

    /test
    /bin
    Microsoft.Web.UI.WebControls.dll
    /webctrl_client
    /1_0
    /images
    /treeimages
    treeview.aspx
    state_city.xml
    web.config

    Now I introduced forms based authentication and the treeview control will stop processing the xml file.

    all the above are downloaded from asp.net website only
  • Re: TreeView Control Issue..

    01-14-2004, 11:20 AM
    • Participant
      1,014 point Participant
    • markberr
    • Member since 07-28-2003, 11:13 AM
    • Microsoft
    • Posts 205
    • AspNetTeam
    Does the control work when running the site via IIS? I want to see if this is really a Cassini issue.


    This posting is provided "AS IS" with no warranties, and confers no rights.
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: TreeView Control Issue..

    01-22-2004, 2:22 PM
    • Member
      347 point Member
    • Kiliman
    • Member since 08-08-2002, 4:41 AM
    • Virginia
    • Posts 70
    In Cassini, unlike IIS, all files except for the /aspnet_client scripts are passed to the HttpRuntime. In IIS, only those extensions that are mapped to the ASP.NET Isapi Extension will be processed by the runtime.

    The problem with this is that if you enable forms authentication and static resources like images, stylesheets, and XML files are stored in a protected folder, ASP.NET will deny access to them until the user is authenticated.

    I noticed the first time I enabled forms authentication and set <deny users="?" />. When I was sent to the Login page, none of the images or stylesheets were loaded!

    To work around this:

    1) Create a new folder called 'public' and move all your static files there
    2) Add a new Web.config file in the 'public' folder with the contents:
    <configuration>
    
    <system.web>
    <authorization>
    <allow users="*" />
    </authorization>
    </system.web>
    </configuration>


    This folder will allow all users access, so only put files in there that you don't want protected.

    Another option would be to hack Cassini to check the file extension of the request. If it's one of the ASP.NET files, then send it to the runtime, otherwise send it directly to the client.

    Add this method to the Request class.
    private static String[] s_aspNetExtensions = new String[] { 
    
    ".asax", ".ascx", ".ashx", ".asmx", ".aspx", ".axd",
    ".vsdisco", ".rem", ".soap", ".config", ".cs", ".csproj",
    ".vb", ".vbproj", ".webinfo", ".licx", ".rex", ".resources" }

    private bool ProcessStaticFile()
    {
    if (_verb != "GET")
    return false;

    // check if file exists
    if (!File.Exists(_pathTranslated))
    return false;

    // last element extension-less?
    int i1 = _pathTranslated.LastIndexOf('\\');
    int i2 = _pathTranslated.IndexOf('.', i1);
    if (i2 < i1)
    return false;

    string extension = _pathTranslated.Substring(i2);

    // loop through extensions
    foreach (string aspNetExtension in s_aspNetExtensions)
    {
    // is it ASP.NET? if so, get out of here
    if (extension == aspNetExtension)
    {
    return false;
    }
    }

    // must be a static file, so send the file directly to the client
    _conn.WriteEntireResponseFromFile(_pathTranslated, false);
    return true;
    }


    Then add a call to ProcessStaticFiles() in the method Request.Process()

    public void Process() {
    

    [snip code]

    // special case for directory listing
    if (ProcessDirectoryListingRequest()) {
    return;
    }

    // static files
    if (ProcessStaticFile())
    {
    return;
    }

    PrepareResponse();

    // Hand the processing over to HttpRuntime

    HttpRuntime.ProcessRequest(this);
    }



    Good luck!

    Kiliman
Page 1 of 1 (3 items)