Asp2.0下Login.Aspx页面和VS2005登陆控件冲突问题

有句老话说,常在河边走,哪能不湿鞋,呵呵,今天终于让我遇到了。

VS2005项目中,若有个页面文件是Login.aspx,即类名为Login,这样就会和VS2005中自带的登陆控件的类名起冲突,在本地VS项目文件下调试或浏览一切都没有问题,若是选择发布的话,那浏览到这个文件的时候就会出错。

错误信息如下所示:

((Login)(this)).AppRelativeVirtualPath = "~/login.aspx";

它的意思是说需要把Login.aspx这个文件进行转化,转化成Login登陆控件的时候,那当然会出错拉,这样都还不错,那简直是奇迹了。

翻遍了CSDN也没有找到类似问题,呵呵,可能是还没有人遇到过吧?或者是遇到了,但就只是把文件名一改,能运行就算了解决问题了。

下面说明下问题产生的原因和解决办法:
1、必须是在2005下,2.0 Framework下才会有这个问题,2003,1.1下是肯定不会有这个问题的,因为Login登陆控件是VS2005才加的东东,很多人说比较实用,不过我是不怎么喜欢。
2、项目文件中,文件名必须是Login.aspx或者其他的登陆控件的类名和VS2005中带的控件类名相同了才可能会出这个问题,所以这里建议大家,文件命名的时候,最好不要和VS2005的控件名一样了,否则出这出那的问题,白白浪费了很多调试的时间,因为这样的问题,在VS下面,本地浏览是没有错误的,只有Publish下才会有问题。

解决办法:
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. It does not resolve to be that in the codebehind assembly 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" %>或者不要使用Login.aspx(Login为类名) 文件名,其中theNs为命名空间名称.

最好不要起Login.aspx这个名字;
posted @ 2007-05-29 22:24  二楼后座  阅读(809)  评论(2编辑  收藏  举报