Access to the path is denied.

Posted on 2009-12-17
Last Modified: 2013-11-26
I have a webpage with the following process that executes during a page load:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim writer As New StreamWriter("\\websrv\Inetpub\wwwroot\kmlTest\hello.txt")
        writer.Write("Why hullo thar")
    End Sub

As you can see, I'm attempting to write to folder being held on another server in my local network. When I access the page, I get the following error:

Access to the path '\\websrv\Inetpub\wwwroot\kmlTest\hello.txt' is denied.

I immediately knew this would be corrected by going to the folder kmlTest on the webSrv and granting the correct permission(s). I granted the user "Network Service" permission with full control and no luck. I have tried to add so many different users but I still can't figure out way it is denying.

I would sincerely appreciate any efforts to help with this problem!
Question by:dcmorrell
    LVL 15

    Accepted Solution

    If you are using anonymous access then the issue is probably due to the anonymous account you are running under does not have sufficient permissions to the location you are writing to.  You can try running the anonymous account as a domain account rather than the default IUSR, and give that account write permissions to the network location.  Or, if you aren't using anonymous and are instead using integrated authentication, give the Authenticated Users group (or limit to a select domain group) write permissions to that location.

    Another thing you may want to play around with is giving write permissions within IIS.  This is done by going to the properties of your website-->home directory tab.
    LVL 4

    Expert Comment

    Actually it is not the "Network Service" that need's the permission it is your computer.
    Try giving "full control" to your computer name on that folder.
    LVL 13

    Expert Comment

    Two things to do to get this working.

    Assume the IIS server that hosts this webpage is called iisserver.

    On the other server (websrv in your example), you have shared out the inetpub directory.  You need to ensure that the iisserver computer account has full control to this share.  Do this by modifying the share permissions and add computer account iisserver$

    Also add this account (iisserver$) to the ntfs permissions of the kmlTest folder.  Remember, when adding this computer account, you need to select the 'Object Types...' button and tick the computer checkbox, otherwise it wont find the computer account.

    This also assumes iisserver and websrv are on the same domain.
    LVL 7

    Expert Comment

    Give full control to kmlTest folder which is in the following path specified.,


    now you application creeps fine..

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now