Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / February 2006

Tip: Looking for answers? Try searching our database.

UnauthorizedAccessException

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DearManasi@gmail.com - 31 Jan 2006 11:20 GMT
Hi,

I have written a ASP.NET web service . It contains a method called
WriteMessage(). This method creates a .txt file on c drive and writes
some message to it.

Now I have created a ASP.NET web application. I am calling the
WriteMessage()  method from this web application. But it is throwing
UnauthorizedAccessException.

The exception is as follows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
System.UnauthorizedAccessException: Access to the path
'c:\NSWebService.txt' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
access, Int32 rights, Boolean useRights, FileShare share, Int32
bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String
msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, FileOptions options)
at Service.WriteMessage()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

What should I do to obtain the nexessary permissions?
Please help.

Mana
Josh Twist - 31 Jan 2006 12:31 GMT
The problem here is that the ASPNET user account does not have
permissions to write to the C:\.

If you've managed to make your web service work when 'playing' with it
I'll wager that you are using the ASP.NET development server provided
with Visual Studio 2005 (.NET 2.0) - this operates under YOUR user
account permissions (probably Administrator). Don't use it, it's
dangerous for this very reason!

The quickest solution here is to give your ASPNET user account write
permissions to the files/folders necessary. I would strongly recommend
you create a custom folder and not give the ASPNET account full
permissions over your whole C:\ though! You could also consider
impersonation etc.

Josh
http://www.thejoyofcode.com/
Mana - 01 Feb 2006 04:53 GMT
Hi Josh,

I created one custom folder and gave ASPNET user necessary permissions.
It worked.
Thanks a lot.

Mana

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.