问题描述
错误提示:ServerErrorin'/'Application.--------------------------------------------------------------------------------ParserErrorDescription:Anerroroccurredduringtheparsingofaresourcerequiredtoservicethisrequest.Pleasereviewthefollowingspecificparseerrordetailsandmodifyyoursourcefileappropriately.ParserErrorMessage:CouldnotloadtypeSystem.Web.UI.WebControls.LoginfromassemblySystem.Web,Version=1.0.5000.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a.SourceError:Line11:<tr>Line12:<tdheight="52"align="center">Line13:<asp:LoginID="Login1"runat="server"BackColor="#F7F7DE"Line14:BorderColor="#CCCC99"Line15:BorderStyle="solid"BorderWidth="1px"SourceFile:E:aspxLogon.aspxLine:13--------------------------------------------------------------------------------VersionInformation:Microsoft.NETFrameworkVersion:1.1.4322.2407;ASP.NETVersion:1.1.4322.2407文件web.config代码__________________<?xmlversion="1.0"encoding="utf-8"?><configuration><appSettings><addkey="ConnectionString"value="dataBOOK.mdb"/></appSettings><system.web><compilationdefaultLanguage="c#"debug="true"/><customErrorsmode="Off"/><authenticationmode="Windows"/><authorization><allowusers="*"/></authorization><traceenabled="false"requestLimit="10"pageOutput="false"traceMode="SortByTime"localOnly="true"/><sessionStatemode="InProc"stateConnectionString="tcpip=127.0.0.1:42424"sqlConnectionString="datasource=127.0.0.1;Trusted_Connection=yes"cookieless="false"timeout="20"/><globalizationrequestEncoding="gb2312"responseEncoding="gb2312"/><pagesvalidateRequest="false"/></system.web></configuration>logon.aspx________________<%PageLanguage="C#"AutoEventWireup="true"CodeFile="Logon.aspx.cs"Inherits="Logon"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>Login.axp</title></head><body><formid="form1"runat="server"><tableheight="100%"cellSpacing="0"cellpadding="0"width="100%"border="0"><tr><tdheight="52"align="center"><asp:LoginID="Login1"runat="server"BackColor="#F7F7DE"BorderColor="#CCCC99"BorderStyle="solid"BorderWidth="1px"Font-Names="Verdana"Font-Size="10px"OnAuthenticate="OnAuthenticate"><TitleTextStyleBackColor="#6B696B"Font-Bold="True"ForeColor="#FFFFFF"/></asp:Login><br/><ahref="CreateUser.aspx">newuserregister</a></td></tr></form></body></html>文件logon.aspx.cs代码_____________usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingSystem.Data.OleDb;publicpartialclassLogon:System.Web.UI.Page{//用户身份验证publicvoidOnAuthenticate(objectsender,AuthenticateEventArgse){boolAuthenticated=false;Authenticated=SiteSpecificAuthenticationMethod(Login1.UserName,Login1.Password);e.Authentciated=Authenticated;}//在数据库中检验privateboolSiteSpecificAuthenticationMethod(stirngUserName,stringpassword){stringstrUserName,strPWD;//NAMEKEY;stringstrSql;//SQLOleDbDataReadermyReader;strUserName=Login1.UserName;strPWD=Login1.Password;strSql="select*fromUserswhereuserid='"+strUserName+"'";clsDBdbo=newclsDB();myReader=dbo.GetResultAsDataReader(strSql);if(myReader.Read()){//存在此用户stringstrUserPwd=myReader["userpassword"].ToString();if(strPWD==strUserPwd){//密码正确Response.Redirect("~/default.aspx");myReader.Close();myReader.Dispose();dbo.killMe();returntrue;}else{Login1.FailureText="密码错误";myReader.Close();myReader.Dispose();dbo.killMe();returnfalse;}}else{//用户不存在Login1.FailureText="用户不存在";myReader.Close();myReader.Dispose();dbo.killMe();returnfalse;}}protectedvodiPage_Load(objectsender,EventArgse){}}文件App_Code/clsDB.cs代码__________________usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingSystem.Data.OleDb;publicclassclsDB{publicOleDBConnectionConncetion;publicclsDB(){Connection=newOleDBConnection(connectionString());Conncetion.Open();}privatestringconnectionString(){returnSystem.Configuration.ConfigurationManger.AppSettings["ConnectionString"];}publicOleDbDataReaderGetResultAsDataReader(stringstrSql){OleDbCommandcommand=newOleDbCommand(strSql,Connection);if(Connection.State==ConnectionState.Closed)Connection.Open();returncommand.ExecuteReader();}publicstringExecuteNoReturn(stringstrSql,stringstrTip){stringstrReturn;OleDbCommandmyCommand=newOleDbCommand(strSql,Connection);try{if(Connection.State==ConnectionState.Closed)Connection.Open();myCommand.ExecuteNonQuery();strReturn=strTip+"succeed";}catch{strReturn=strTip+"false";}myCommand.Dispose();Conneciton.Close();returnstrReturn;}publicvoidkillMe(){Connection.Dispose();}}
解决方案
解决方案二:
logon.aspx________________<%PageLanguage="C#"AutoEventWireup="true"CodeFile="Logon.aspx.cs"Inherits="Logon"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>Login.axp</title></head><body><formid="form1"runat="server"><tableheight="100%"cellSpacing="0"cellpadding="0"width="100%"border="0"><tr><tdheight="52"align="center"><asp:LoginID="Login1"runat="server"BackColor="#F7F7DE"BorderColor="#CCCC99"BorderStyle="solid"BorderWidth="1px"Font-Names="Verdana"Font-Size="10px"OnAuthenticate="OnAuthenticate"/><TitleTextStyleBackColor="#6B696B"Font-Bold="True"ForeColor="#FFFFFF"/></asp:Login><br/><ahref="CreateUser.aspx">newuserregister</a></td></tr></form></body></html>少了个/
解决方案三:
publicpartialclassLogon===============这里换一个类名,比如LoginFormpublicpartialclassLoginForm别忘了aspx也要修改<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Login.aspx.cs"Inherits="LoginForm"%>你的类名和ASP.NET提供的控件名冲突了
解决方案四:
Microsoft.NETFrameworkVersion:1.1.4322.2407;ASP.NETVersion:1.1.4322.2407===貌似用的.NET1.1,那应该不是我刚才提到的问题,sorry