发布网站时CS0030: Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'

来源:互联网 发布:网页淘宝登陆 编辑:程序博客网 时间:2024/05/09 01:31

架设网站时遇到共三个问题,搞了好久才弄出来,记下先。

遇到的第一个问题。先是按照网上说的。

帐户登录界面的文件叫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.csLine: 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
      {


遇到的第二个问题:打开网站时总是提示要输入用户和密码进行连接

在虚拟目录右键属性,找到目录安全性-编辑-匿名访问 勾上,直接确定就好的。


遇到的第三个问题。

Could not write to output file 'c:/WINDOWS/Microsoft.NET/Framework/v2.0.5072

错误的处理:

出现CS0016的原因一般是临时目录的权限不够,我遇到的是只有特殊访问权限,其他都没有,解决的办法是给Windows目录下的临时文件夹Temp的安全选项卡中加入NetWork Service(其实默认的好像是4个权限就够了)用户并赋予基本的权限,如浏览,读取那几个,具体自己试试,实在不行就完全控制。



原创粉丝点击