發布網站時CS0030: Cannot convert type ‘ASP.login_aspx’ to ‘System.Web.UI.WebControls.Lo

來源:互聯網
上載者:User
帳戶登入介面的檔案叫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 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" %>

  再試試就沒問題了。

 

  二是頁面基類增加命名空間

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

  namespace EtrmsWeb
  {

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

  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.