asp.net的Login.aspx.cs出错解决办法

在做CRM的时候,帐户登录界面的文件叫Login.aspx,后台代码为Login.aspx.cs

在VS.NET 2005下测试通过,可发布后,在IIS下运行,则有如下错误提示。

===============================================================================

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0030: Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'

Source Error:

 
Line 114:        public login_aspx() {
Line 115:            string[] dependencies;
Line 116:            ((Login)(this)).AppRelativeVirtualPath = "~/Login.aspx";
Line 117:            if ((global::ASP.login_aspx.@__initialized == false)) {
Line 118:                global::ASP.login_aspx.@__stringResource = this.ReadStringResource();

Source File: c:/WINNT/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/21f002dd/13ab9d48/App_Web_login.aspx.cdcab7d2.vqjr2cxo.0.cs    Line: 116

Compiler Warning Messages:

Server Error in '/' Application.

Compilation Error

 

Warning: CS0108: 'ASP.login_aspx.Profile' hides inherited member 'Login.Profile'. Use the new keyword if hiding was intended.
Source Error:

Warning: CS0108: 'ASP.login_aspx.ApplicationInstance' hides inherited member 'Login.ApplicationInstance'. Use the new keyword if hiding was intended.
Source Error:

Show Detailed Compiler Output:

Show Complete Compilation Source:

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

 

===========================================================================

这是因为.NET Framework 2.0 版中新增Login类.而我们又增加Login.aspx,就会有冲突。

解决法办:

把原来这个

public partial class Login : System.Web.UI.Page
{

...

}

改为别的,如

public partial class AccountLogin : System.Web.UI.Page
{

...

}

aspx文件里的也要改动,如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" Culture="auto" UICulture="auto" %>

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="AccountLogin" Culture="auto" UICulture="auto" %>

再试试就没问题了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的 ASP.NET 登录示例: 1. 在 Visual Studio 中创建一个新的 ASP.NET 网站项目。 2. 在项目中创建一个名为 "Login.aspx" 的新网页。 3. 将以下代码添加到 Login.aspx 页面中: ``` <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="YourNamespace.Login" %> <!DOCTYPE html> <html> <head> <title>Login</title> </head> <body> <form id="form1" runat="server"> <div> <h2>Login</h2> <p> <label>Username:</label> <asp:TextBox ID="txtUsername" runat="server"></asp:TextBox> </p> <p> <label>Password:</label> <asp:TextBox ID="txtPassword" TextMode="Password" runat="server"></asp:TextBox> </p> <p> <asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" /> </p> </div> </form> </body> </html> ``` 4. 在 Login.aspx.cs 文件中添加以下代码: ``` using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace YourNamespace { public partial class Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnLogin_Click(object sender, EventArgs e) { // 获取用户名和密码 string username = txtUsername.Text.Trim(); string password = txtPassword.Text.Trim(); // 在此处编写验证用户名和密码的代码 if (username == "admin" && password == "admin") { // 验证通过,将用户重定向到另一个页面 Response.Redirect("Welcome.aspx"); } else { // 验证失败,显示错误消息 Response.Write("Invalid username or password."); } } } } ``` 5. 运行项目并在浏览器中打开 Login.aspx 页面。输入用户名和密码,然后单击 "Login" 按钮进行登录。 以上示例仅供参考,实际应用中需要根据具体的需求进行修改和完善。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值