Rahul Soni's blog

Never assume the obvious is true!

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

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

  • Comments 27

Another issue which I found really interesting... We had an ASP.NET 2.0 application and in one of the pages (called Login.aspx) we used the Login control. It worked beautifully from the IDE (F5 or CTRL+F5), but when we deployed it on the webserver (precompiled), it showed the following error.

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

Source Error:
Line 112: public login_aspx() {
Line 113: string[] dependencies;
Line 114: ((Login)(this)).AppRelativeVirtualPath = "~/Login.aspx";
Line 115: if ((global::ASP.login_aspx.@__initialized == false)) {
Line 116: dependencies = new string[1];

Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\cpi.operations.field.assv\32f5e4c7\5ac0558e\App_Web_login.aspx.cdcab7d2.crjut9bu.0.cs Line: 114

Clearly, it was looking like a name conflict. We changed the name of the page class from Login to Login1 and re-deployed on the webserver and it worked fine, as expected.

Moral of the story... in 2.0, don't use Login as a class name if you intend to use the Login Control. It is not really that big a compromise, specially if you consider the functionality of Login control!! Besides, you can always name your page as Login.aspx. All you need to ensure is that, the name of the class of that page is NOT called Login.

PS. It is not that naming a class as Login WILL run into problems, but just in case you get the above error and your symptoms match,  I hope this might help you...

Cheers!
Rahul

  • I had the same problem but this time because of the Calendar Control :)

    Great help :D, thanks
  • Maybe it could give us a warning ata build time...
  • Basically, it is because of the change in compilation model in 2.0.

    http://msdn.microsoft.com/msdnmag/issues/06/01/ExtremeASPNET/

    Hope this helps!
  • my page was named Login.aspx and gave the same error; i have chabged the name and now it works
  • Great help!

    I had this issue + the issue with a page named Error.aspx, I had to rename the inherited class to Error1 and it worked.
  • this link will throw light on this issue

    http://heybo.com/weblog/posts/524.aspx
  • Same problem, same solution - rename the class.

    How many times will I fall into this trap !!!!

  • Thanks for the post :)

  • I had the same error with a page named menu.aspx so don´t use menu as page name

  • I had the same problem with a page called View.aspx, so I guess that is also a name to avoid... It disappeared when I renamed to ViewSpecimen.aspx

  • Thanks Rahul

    I also found that changepassword.aspx has the same issue.

  • Thanks, Rahul! This really helped me out.

  • We had the same issue. Renaming of the class workded like charm. But what if you need to have class name that get in conflict? (in our case the class was named Content). This is where namespaces become handy!

    Cheers,

    George S.

  • We had this error. We cleared the problem up by examing the page directive in Login.aspx. We noticed that the Inherits="Login" had a specific reference to an assembly, as in Inherits="Login, blah-blah".  We deleted the ", blah-blah" and that fixed the problem.

  • I have same problem, thank 4 u solution

Page 1 of 2 (27 items) 12
Leave a Comment
  • Please add 5 and 8 and type the answer here:
  • Post