Microsoft KB Archive/313105

= FIX: Cannot Compile Code-Behind Files That Use Src Attribute on a UNC Share =

Article ID: 313105

Article Last Modified on 3/26/2003

-

APPLIES TO


 * Microsoft ASP.NET 1.0
 * Microsoft .NET Framework 1.0

-



This article was previously published under Q313105



SYMPTOMS
When you compile a Web form, the compilation may fail in ASP.NET, and you may receive the following error message (or similar):

Compiler Error Message: CS2001: Source file

'\\server\sharename\webform1.aspx.cs' could not be found.

This error can occur if the following conditions are true:
 * The code-behind model is being used.
 * The page uses dynamic compilation with the Src attribute, and the Src attribute points to a file on a remote computer by using a Universal Naming Convention (UNC) share.
 * Impersonation is enabled in the Web.config file.



CAUSE
This problem occurs because the compiler is started with the identity of a worker process, and the worker process may not be able to read the remote share. Because ASP.NET uses the impersonation token to read the page, ASP.NET reads the page successfully.



RESOLUTION
To resolve this problem, use one of the following methods:
 * Give the share access to the account that is used for the worker process. If you are using a system account or a network service, you can give access to the computer account.

To give access to the computer account, follow these steps:
 * Right-click the share, and then click Properties.
 * On the Sharing tab, click Permissions, and then click Add.
 * Type the name of the Web server, and then click Check Names. This displays as $machinename under Share Permissions in the Permissions dialog box for this share.
 * Use code-behind files with precompiled dynamic-link libraries (DLLs) instead of dynamic compilation.
 * Use single page files rather than code-behind files.
 * Run the worker process as an account that can access the share. To configure this, use the user name and password attributes of the processModel element of the Machine.config file.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in ASP.NET (included with the .NET Framework) 1.1 and the .NET Framework 1.1.



Steps to Reproduce Behavior
 Create an .aspx page named Webform1.aspx.  Use one of the following examples for the page directive: <%@ Page language=&quot;c#&quot; Codebehind=&quot;WebForm1.aspx.cs&quot;  Src = &quot;WebForm1.aspx.cs&quot; %>

-or-

<%@ Page language=&quot;vb&quot; Codebehind=&quot;WebForm1.aspx.vb&quot;  Src = &quot;WebForm1.aspx.vb&quot; %>  Create a code-behind page, and name it according to the page directive that you chose in step 2. Add a domain user (domain\user) as an Administrator to the computer. Create a share, and then give full permissions to the domain user only.</li> In Internet Service Manager, create a Microsoft Internet Information Server (IIS) application, and then use the domain\user for connect-as.</li> Create a virtual directory in the application that points to the share that you created earlier.</li> Move the WebForm1.aspx and the code-behind file to the share.</li>  Create a new Web.config file, and then add the following code: <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?> <system.web> <authentication mode=&quot;Windows&quot; /> <identity impersonate=&quot;true&quot; userName=&quot;domain\user&quot; password=&quot;password&quot; /> </system.web> </li> Copy the Web.config file into the virtual directory for the Web application to add the file to the IIS application.</li> Browse to the page.</li></ol>

Additional query words: kbreadme codebehind

Keywords: kbbug kbfix kbnofix kbweb kbsecurity kbreadme kbconfig kbdeployment KB313105

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.