Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 908158 - Last Review: December 3, 2007 - Revision: 1.2
Error message when ASP.NET 2.0 is configured to run with a user account: "Unable to generate a temporary class"
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
This issue occurs if the user account does not have the
List Folder Contents and Read permissions on the %windir%\Temp
folder.
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 Path
Note Path 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
User
Note User 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.
- Click Start, click Run,
type cmd, and then click OK.
- At the command prompt, type iisreset
/restart, and then press ENTER.
- Create a Web.config file, and then add the following code example to
the Web.config file.
Note <Server> represents the name of the
server, <User> represents the user name,
<Password> represents the password for the user, and
<Catalog> represents the catalog name.<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="Off" />
<profile defaultProvider="SqlPProvider" enabled="true">
<providers>
<add name="SqlPProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=1.2.3400.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="SqlPProviderConnection" />
</providers>
<properties>
<add name="FavoriteURLs" type="System.Collections.Specialized.StringCollection" readOnly="false" serializeAs="Xml" />
</properties>
</profile>
<anonymousIdentification enabled="true" cookieless="UseDeviceProfile" />
<authentication mode="Forms">
<forms>
<credentials passwordFormat="Clear">
<user name="a" password="a" />
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
<connectionStrings>
<add name="SqlPProviderConnection" connectionString="server=<Server> ;UID=<User>;PWD=<Password>;Initial Catalog=<Catalog>" />
</connectionStrings>
</configuration> - Create a file that is named Login.aspx, and then add the
following code example to the Login.aspx file.
<%@ Page LANGUAGE="cs" %>
<form runat=server>
<asp:literal runat=server id="MyText" Text=""></asp:literal>
<asp:TextBox runat=server id="UsernameTextBox" Text="Type a user name"></asp:TextBox>
<asp:TextBox runat=server id="PasswordTextBox" Text="Type a password"></asp:TextBox>
<asp:Button id="Submit" Text="Submit" runat="server"/>
</form>
<script runat="server" >
protected void Page_Load(Object source, EventArgs e)
{
MyText.Text += "[Login Page: you are not authenticated]<br>";
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);
}
}
</script> - Create a file that is named Test.aspx, and then add the following code example to the Test.aspx file.
<%@ Page LANGUAGE="cs" Debug="true" %>
<form runat="server">
<asp:Literal runat="server" id="Literal1" Text=""></asp:literal>
<asp:Button text="Signout" OnClick="Signout_Click" id="SignOutButton" runat=server/>
</form>
<script runat="server" >
void Page_Load(object sender, EventArgs e)
{
Literal1.Text += "[User.Identity.Name=" + User.Identity.Name +"]<br>";
Profile.FavoriteURLs = new System.Collections.Specialized.StringCollection();
Profile.FavoriteURLs.Add("MyString1");
Profile.FavoriteURLs.Add("MyString2");
Profile.FavoriteURLs.Add("MyString3");
if (Profile.FavoriteURLs != null) {
for (int i=0; i<Profile.FavoriteURLs.Count; i++) {
Literal1.Text += "[FavoriteURLs=" + Profile.FavoriteURLs[i] + "]<br>";
}
}
}
void Signout_Click(Object sender, EventArgs E) {
System.Web.Security.FormsAuthentication.SignOut();
Response.Redirect(System.Web.Security.FormsAuthentication.LoginUrl);
}
</script> - Request Test.aspx.
APPLIES TO
- Microsoft .NET Framework 2.0
| kbtshoot kberrmsg kbcode kbprb KB908158 |
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