Hi there, From the error description in your post, I guess that before publishing the web site, the web page login.aspx uses the code behind file that contains the partial class named Login. If this is the case, then the problem is the name of the partial class Login. As you may already know that at runtime the ASP.NET generates a dynamic class reprenting the web page, if the web page either uses the code behind file or the Page directive does not specify the Inherits attribute, then by default the dynamic class should contains something like:
...((System.Web.UI.Page)(this)).AppRelativeVirtualPath = "~/Login.aspx";...
The System.Web.UI.Page is specified in the casting operation, not the base class of the Login web page. If the Page directive specifies the base class in the Inherits attribute and the CodeFile attribute is not used. Then the System.Web.UI.Page is replaced with the base class name:
((Login)(this)).AppRelativeVirtualPath = "~/Login.aspx";
Unfortunately, the Login name is the same as the Login control defined in the System.Web.UI.WebControls namespace, so as a result it causes the compilation error of the invalid casting operation. If you have a look at the Page directive of the web page Login.aspx after publishing the web site, you will see that only the Inherits attribute is specified. So to fix the error, you simply replace the name Login of the partial class with another one, say _Login, and also update the Inherits attribute.