Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP.Net File Upload in Windows 2003 Server

Posted on 2004-08-17
4
Medium Priority
?
3,107 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 1000 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 1000 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

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

636 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