Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 21st, 2005, 07:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default Limit access to upload page functionality

Well, here is a problem...

In the web application, which I am doing, logged on users can upload files using a Java applet, which is embedded in the .aspx page. The applet posts an HTTP request to an .aspx page on the same server as the logged in user is.

I am trying to figure out a way to prevent that non-authorized people do not upload files as well. Since the user is already logged on I was wondering if one could pass the session ID to the applet and let the applet include it in the HTTP request, and then validate before the uploading is happens (server-side) that the session ID posted exists (user logged on).

The problem is not to pass the session ID back and forth. The problem is to validate that the session ID exists. Is it possible to make such inquiry? I guess it would be a security risk, right?

If this will not work, how can I provide the wanted functionality?

Thanks, Jacob.
__________________
Danish audio books for download at http://www.lytenbog.dk (Danske lydbøger til download).
 
Old November 23rd, 2005, 02:42 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You can use Forms Authentication for your project. Or you can do your own validation on the page. In the Page_Load, do a check, if the user is not authorized to upload, redirect to an error page, stating "You do not have rights to upload" Something like that should work.

 
Old November 23rd, 2005, 03:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, but that would require that the applet users to enter username and password in the applet itself again, eventhough they are already logged on to the web application, and I would like a solution without this; the user is already logged on to the .aspx page/application.

The .aspx page, which is handling the upload is merely a standalone page, which only process an upload request and nothing more. Something like this...
Code:
    public void Page_Load(Object oSender, EventArgs eArg)
    {
        int uploaded = 0;
        this.Response.Clear();
        this.Response.BufferOutput = true;
        this.Response.ContentType = "text/ascii";
        try
        {
            ...

            HttpPostedFile file;
            foreach(string f in this.Request.Files.AllKeys)
            {
                try
                {
                    file = this.Request.Files[f];
                    file.SaveAs(path + ((path.EndsWith(@"\"))? "" : @"\")
                            + System.IO.Path.GetFileName(file.FileName));
                        this.Response.Write(System.IO.Path.GetFileName(file.FileName) + " (uploaded)\n");
                        uploaded++;
                }
                catch(Exception e)
                {
                    this.Response.Write("- File upload of '" + f + "' failed. " + e.Message);
                }
            }
        }
        catch(Exception e)
        {
            this.Response.Write("Exception: " + e.Message + "\n");
        }
        this.Response.Write(uploaded + " files were succesfully uploaded.\n");
        this.Response.End();
    }
    Since it is an applet, the user do not leave the page in which the applet resides. The upload is then another session... unfortunately. I would like it to be the same. All the login stuff is done for the web application but I have been forced to make a Java applet in order to select multiple files for upload, and this solution unfortunately introduce these other authorization problems.

Jacob.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting Page Limit (no of lines per page) snufse Crystal Reports 1 May 26th, 2008 08:02 AM
ch. 2 what is the file size limit to upload? cluce BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 February 19th, 2008 04:48 PM
Problems regarding upload functionality jacob Javascript 1 January 2nd, 2007 06:38 AM
how to limit the size of upload image? rockercheng Classic ASP Basics 1 August 8th, 2003 01:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.