I ran into an interesting error today and for a minute I didnt understand why it occurred.
Exception
c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\exampleapp\571e5472\336672e2\App_Web_login.master.cdcab7d2.gh4qw4cs.0.cs(115): error CS0030: Cannot convert type ‘ASP.login_master’ to ‘System.Web.UI.WebControls.Login’
http://localhost/exampleapp/login.aspx?ReturnUrl=/exampleapp/default.aspx
/exampleapp/login.aspx
The site ran fine when running under the local cassini web web server but when we pre-compiled the website through our continuous integration system and then dropped it on our test server, everything went hay-wire. This error started popping up.
After a few moments of reviewing the error I figured it out.
The problem
The master page code behind class was called “Login”. ASP.NET 2.0 also has a class by the name of Login. The .NET Framework was trying to convert one type (the master page type) to the actual Login class type.
The Fix
You can fix this one of two ways.
1. Give the full type name in the inherits attribute of the master page.
e.g.: NameSpace.Type
2. Change the code behind class name from “Login” to something like “LoginMaster”.
Conclusion
As I found (after the fact of solving this) Rahul Soni to say … “dont give a class the name of ‘Login'”.
Please note, I’ve also see this problem with class names that are of the following:
- Error
- View
- Wizard
I’m sure there are more, but these are the ones I’ve see cause this problem before.
Leave a Reply
You must be logged in to post a comment.