Microsoft KB Archive/908158

= Error message when ASP.NET 2.0 is configured to run with a user account: &quot;Unable to generate a temporary class&quot; =

Article ID: 908158

Article Last Modified on 12/3/2007

-

APPLIES TO


 * Microsoft .NET Framework 2.0

-





SYMPTOMS
Consider the following scenario:
 * You create a Microsoft ASP.NET 2.0 application.
 * ASP.NET 2.0 is configured to run with a user account.
 * The SerializeAs attribute of the Profile property in ASP.NET 2.0 is set to Xml.

In this scenario, ASP.NET 2.0 may not save the user profile, and you may receive an error message that is similar to the following:

[InvalidOperationException: Unable to generate a temporary class (result=1).

error CS2001: Source file 'D:\WINDOWS\TEMP\d0lurtzx.0.cs' could not be found

error CS2008: No inputs specified



CAUSE
This issue occurs if the user account does not have the List Folder Contents and Read permissions on the %windir%\Temp folder.



RESOLUTION
To resolve this issue, grant the user account the List Folder Contents and Read permissions on the %windir%\Temp folder.



Steps to reproduce the issue
 Create a Web site in Microsoft Internet Information Services (IIS) Manager. Create a local Microsoft Windows NT user account. Click Start, click Run, type cmd, and then click OK. At the command prompt, type the following command:

cd

Note  represents the path of the Microsoft .NET Framework 2.0 folder on the computer. At the command prompt, type the following command, and then press ENTER:

aspnet_regiis -ga

Note  represents the user account that you created in step 2. Change the application pool identity for the Web site that you created in step 1 to the account that you created in step 2.</li> Click Start, click Run, type cmd, and then click OK.</li> At the command prompt, type iisreset /restart, and then press ENTER.</li>  Create a Web.config file, and then add the following code example to the Web.config file.

Note  represents the name of the server,   represents the user name,   represents the password for the user, and   represents the catalog name. <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <system.web> <customErrors mode=&quot;Off&quot; /> <profile defaultProvider=&quot;SqlPProvider&quot; enabled=&quot;true&quot;> <add name=&quot;SqlPProvider&quot; type=&quot;System.Web.Profile.SqlProfileProvider, System.Web, Version=1.2.3400.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot; connectionStringName=&quot;SqlPProviderConnection&quot; /> <add name=&quot;FavoriteURLs&quot; type=&quot;System.Collections.Specialized.StringCollection&quot; readOnly=&quot;false&quot; serializeAs=&quot;Xml&quot; /> <anonymousIdentification enabled=&quot;true&quot; cookieless=&quot;UseDeviceProfile&quot; /> <authentication mode=&quot;Forms&quot;> <credentials passwordFormat=&quot;Clear&quot;> <user name=&quot;a&quot; password=&quot;a&quot; /> <deny users=&quot;?&quot; /> </system.web> <connectionStrings> <add name=&quot;SqlPProviderConnection&quot; connectionString=&quot;server=<Server> ;UID=<User>;PWD=<Password>;Initial Catalog=<Catalog>&quot; /> </connectionStrings> </li>  Create a file that is named Login.aspx, and then add the following code example to the Login.aspx file. <%@ Page LANGUAGE=&quot;cs&quot; %> <asp:literal runat=server id=&quot;MyText&quot; Text=&quot;&quot;></asp:literal> <asp:TextBox runat=server id=&quot;UsernameTextBox&quot; Text=&quot;Type a user name&quot;></asp:TextBox> <asp:TextBox runat=server id=&quot;PasswordTextBox&quot; Text=&quot;Type a password&quot;></asp:TextBox> <asp:Button id=&quot;Submit&quot; Text=&quot;Submit&quot; runat=&quot;server&quot;/> <script runat=&quot;server&quot; > protected void Page_Load(Object source, EventArgs e) { MyText.Text += &quot;[Login Page: you are not authenticated] &quot;; String strUserName = UsernameTextBox.Text; String strPassword = PasswordTextBox.Text;

bool  fPersist     = false; bool  fVerifed     = System.Web.Security.FormsAuthentication.Authenticate(strUserName, strPassword); if( fVerifed) {         System.Web.Security.FormsAuthentication.RedirectFromLoginPage(strUserName, fPersist); } }

</li>  Create a file that is named Test.aspx, and then add the following code example to the Test.aspx file. <%@ Page LANGUAGE=&quot;cs&quot; Debug=&quot;true&quot; %> <form runat=&quot;server&quot;> <asp:Literal runat=&quot;server&quot; id=&quot;Literal1&quot; Text=&quot;&quot;></asp:literal> <asp:Button text=&quot;Signout&quot; OnClick=&quot;Signout_Click&quot; id=&quot;SignOutButton&quot; runat=server/> <script runat=&quot;server&quot; > void Page_Load(object sender, EventArgs e) {

Literal1.Text += &quot;[User.Identity.Name=&quot; + User.Identity.Name +&quot;] &quot;; Profile.FavoriteURLs = new System.Collections.Specialized.StringCollection; Profile.FavoriteURLs.Add(&quot;MyString1&quot;); Profile.FavoriteURLs.Add(&quot;MyString2&quot;); Profile.FavoriteURLs.Add(&quot;MyString3&quot;);

if (Profile.FavoriteURLs != null) { for (int i=0; i<Profile.FavoriteURLs.Count; i++) { Literal1.Text += &quot;[FavoriteURLs=&quot; + Profile.FavoriteURLs[i] + &quot;] &quot;; }   } }

void Signout_Click(Object sender, EventArgs E) { System.Web.Security.FormsAuthentication.SignOut; Response.Redirect(System.Web.Security.FormsAuthentication.LoginUrl); } </li> Request Test.aspx.</li></ol>

Keywords: kberrmsg kbtshoot kbprb kbcode KB908158

-

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

© Microsoft Corporation. All rights reserved.