Microsoft Knowledge Base Email Alertz

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

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 313105 - Last Review: March 26, 2003 - Revision: 2.2

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

This article was previously published under Q313105

On This Page

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:
    1. Right-click the share, and then click Properties.
    2. On the Sharing tab, click Permissions, and then click Add.
    3. 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.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create an .aspx page named Webform1.aspx.
  2. Use one of the following examples for the page directive:
    <%@ Page language="c#"  Codebehind="WebForm1.aspx.cs"  Src = "WebForm1.aspx.cs" %>
    					
    -or-
    <%@ Page language="vb"  Codebehind="WebForm1.aspx.vb"  Src = "WebForm1.aspx.vb" %>
    					
  3. Create a code-behind page, and name it according to the page directive that you chose in step 2.
  4. Add a domain user (domain\user) as an Administrator to the computer.
  5. Create a share, and then give full permissions to the domain user only.
  6. In Internet Service Manager, create a Microsoft Internet Information Server (IIS) application, and then use the domain\user for connect-as.
  7. Create a virtual directory in the application that points to the share that you created earlier.
  8. Move the WebForm1.aspx and the code-behind file to the share.
  9. Create a new Web.config file, and then add the following code:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <system.web>
        <authentication mode="Windows" />
        <identity impersonate="true" userName="domain\user" password="password" /> 
     </system.web>
    </configuration>
    					
  10. Copy the Web.config file into the virtual directory for the Web application to add the file to the IIS application.
  11. Browse to the page.

APPLIES TO
  • Microsoft ASP.NET 1.0
  • Microsoft .NET Framework 1.0
Keywords: 
kbfix kbbug kbconfig kbdeployment kbnofix kbreadme kbsecurity kbweb KB313105
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please