Welcome to MSDN Blogs Sign in | Join | Help

Rahul Soni's blog

Never assume the obvious is true!

News



  • These postings are provided "AS IS" with no warranties, and confers no rights.
CS0030: Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'

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

Posted: Monday, July 03, 2006 6:09 PM by rahulso

Comments

Kotrim said:

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

Great help :D, thanks
# July 13, 2006 11:08 AM

xiko said:

Maybe it could give us a warning ata build time...
# July 26, 2006 10:13 AM

rahulso said:

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!
# July 27, 2006 7:49 AM

annie said:

my page was named Login.aspx and gave the same error; i have chabged the name and now it works
# August 1, 2006 6:34 AM

Davide said:

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.
# August 14, 2006 5:27 PM

DotNet Circle said:

this link will throw light on this issue

http://heybo.com/weblog/posts/524.aspx
# September 15, 2006 5:47 AM

Andrew Sims said:

Same problem, same solution - rename the class.

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

# November 28, 2006 5:59 AM

Madalina said:

Thanks for the post :)

# December 21, 2006 9:16 AM

AZU said:

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

# January 5, 2007 6:00 PM

Fedor Steeman said:

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

# February 9, 2007 5:26 AM

Andy said:

Thanks Rahul

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

# February 22, 2007 5:33 PM

Robert said:

Thanks, Rahul! This really helped me out.

# March 6, 2007 3:28 AM

George S. said:

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.

# March 10, 2007 6:39 AM

David Rogers said:

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.

# March 13, 2007 8:30 PM

coki said:

I have same problem, thank 4 u solution

# April 2, 2007 12:58 PM

Gayathri said:

Had the same problem.Solved now.Renamed the class and working. Thanks a lot.

# April 9, 2007 2:28 AM

sandipon said:

thanks for this artical , i was facing same problem for fileupload control , but now it sloved

# April 27, 2007 2:36 AM

Atul Kapase said:

Its same as name conflict, just change Page  Class ReportViewer to ReportViewer1

# June 1, 2007 7:20 AM

Niteen Jadhav said:

same problem using Login.aspx with class name Login. changed class name. it works.

Thanks.

# August 9, 2007 5:18 AM

Anders yu said:

the "Login" is saved by c#, so change it.

# November 21, 2007 2:35 AM

Tommy said:

We renamed our class to _Login instead of Login1.

I find the naming of ... well anything... with a number suffix (like Login1, TextBox1, DropDownlist1, etc) simply silly. But VS needs to name it something else, but also you better believe I then rename it to something else ;-)

And yeah; the Login control does really save us a lot of work!

# February 6, 2008 3:55 AM

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# February 6, 2008 8:24 AM

Alochan said:

Just use namespace on each page of ur website

namespace MyNamespace

{

public partial class Login

{

}

}

it will work

Regards

Alochan

# October 13, 2008 1:45 AM

sangam said:

Yeah, i got this problem while deploying my application in my localhost. The treatment I did is to add a namespace in the Login.aspx.cs file and update it from the Login.aspx's Inherits property. Thank you.

# November 12, 2008 12:59 AM

amiya said:

every page has default class (pagename)  but how it become automatically login .

Now How i chane it login to login1 it gives error

# November 12, 2008 5:31 AM

Anuja said:

Thanks Rahul...

It worked for me toooo:)

# January 8, 2009 10:53 PM

Kirtikumar said:

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

# June 23, 2009 5:06 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker