Solved

ASP.Net File Upload in Windows 2003 Server

Posted on 2004-08-17
4
3,103 Views
Last Modified: 2010-05-18
Dear Experts,

Currently I find myself banging my head against a wall.

We wrote a website in ASP.Net. As part of our administration backend, we have an image/document gallery popup-page that is used to upload documents and images to our Windows 2003 Web Edition server. Unfortunatly, it seems that the C# code used to write the file on the server fails autentication , and I get the following exception:

Access to the path "Inetpub/Website/Images/MyImage.jpg" is denied.mscorlib   at System.IO.__Error.WinIOError(Int32 errorCode, String str)
   at System.IO.File.Delete(String path) )

On our windows xp workstations, we were able to get the code working by simply granting the account aspnet write-access. However, this method fails to rememdy the problem on the Windows 2003 server. Which account should one grant access in order to get the upload working?

I think a checklist of steps needed in order to grant asp.net access to certail folders would help a great deal.

Thanks!
0
Comment
Question by:FVDW
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 23

Assisted Solution

by:rama_krishna580
rama_krishna580 earned 250 total points
ID: 11827118
Hi,

Because the Framework built in security does not allow this unless the user that the code is running under (which by default for a Web Service is ASPNET I believe) has rights to the drive.  You need to do one of three things:

1)  Change the rights that the user ASPNET has.  Very bad idea.  Major security issues.

2)  Change the user that the Web Service is running under to one that has the correct rights.  Better than 1) but still a big security risk.

3)  Read up on impersonation and change the code to impersonate a user that has rights to the drive - for only the amount of time that you are actively accessing the files.  Best option from a security standpoint, but most work to get working.  I have had mixed luck with impersonation - but I know that the issues that I have are understanding issues, not implementation issues.

One important thing is ...(if you are using this option) : You can't access mapped drives from a service because mapped drives are user-specific and become available when a physical login takes place. Services don't have an associated user session. Use a UNC path instead.

i think it may help you...
best of luck..

R.K
0
 
LVL 34

Accepted Solution

by:
Dave_Dietz earned 250 total points
ID: 11827479
In 2003/IIS 6.0 the ASPNet account is only used if you are running in IIS 5.0 Compatability Mode - otherwise it runs as whatever account the Application Pool is configured as (Network Service by default).

If you add the IIS_WPG group with Write permissions it may resolve the issue (it contains the accounts that are allowed to run Application pools).

Dave Dietz
0
 

Author Comment

by:FVDW
ID: 11828583
Thanks you guys,

In the end we were able to get the upload working by impersonation. Thank you for pointing out that IIS 6 runs in a network service account, and not the aspnet account we use for development.

I think it might be worthwhile to invest in a good book on IIS6 Administration. Do you have any recommendations for such a book?

Many thanks,

FVDW
0
 
LVL 34

Expert Comment

by:Dave_Dietz
ID: 11831101
ISBN 0-7356-1560-8
Microsoft IIS 6.0 Administrator's Pocket Consultant
Microsoft Press

I like it....  :-)

Dave Dietz
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question