Pages

Search This Blog

Thursday, October 25, 2007

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

Facing an error below and found that i'm not alone.

Posted by Microsoft on 9/29/2005 at 4:46 PM
If you have used a Page that effectively uses a codebehind classname that is the same as say the Login control, that is Login, e.g. your page was called Login.aspx, then when you pre-compile (publish) the web site as an updateable web site, the aspx is retained and tries to compile against a type called Login in the code behind.


Server Error in '/' Application.
--------------------------------------------------------------------------------
Compilation Error


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 118: public login_aspx() {

Line 119: string[] dependencies;
Line 120: ((Login)(this)).AppRelativeVirtualPath = "~/Login.aspx";
Line 121: if ((global::ASP.login_aspx.@__initialized == false)) {
Line 122: dependencies = new string[6];

Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\3e0e0b67\701b7b2\App_Web_login.aspx.cdcab7d2.fhpe1ais.0.cs Line: 120






Many post and solutions can get from the internet. Among them is

  1. Rename Login.aspx to others name like signin.aspx
  2. Try using a classname for your codebehind and defined in the inherits that does not clash with a type in System.Web, e.g. LoginPage, or qualify the class and therefore the inherits statement with a namespace, e.g.<%@ page ... inherits="theNs.Login" %.namespace theNs { public partial class Login : System.Web.UI.Page { .. } }
  3. uncheck “Allow this precompiled site to be updatable” when Publish Web Site in Visual Studio 2005.
Solution no. 3 is good for me. Less work and works 100%.

1 comment:

Unknown said...

Yeah, it worked for me by going through the solution: adding a namespace in the Login.aspx.cs page and updating it in Login.aspx's Inherits property. Thank you,