错误-编译器错误消息:CS0117:“对象"不包含“放弃"的定义 [英] Error -Compiler Error Message: CS0117: 'object' does not contain a definition for 'Abandon'

查看:334
本文介绍了错误-编译器错误消息:CS0117:“对象"不包含“放弃"的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用Session["Name"].Abandon();
时出现此错误

This error is giving when i am using Session["Name"].Abandon();

Compiler Error Message: CS0117: 'object' does not contain a definition for 'Abandon'

Source Error:
Line 993:{
Line 994:FormsAuthentication.SignOut();
Line 995:Session["Name"].Abandon();
Line 996:Response.Redirect("index.aspx");
Line 997:}


我的注销CS代码如下所示:


My CS CODE FOR LOGOUT IS GIVEN BELOW

void logout(Object Sender, EventArgs e)
{
FormsAuthentication.SignOut();
Session["Name"].Abandon();
Response.Redirect("index.aspx");
}

推荐答案

删除索引-会话包含Abandon方法,而不是单个项目...
Take the indexing out - Session contains the Abandon method, not the indicvidual items...
void logout(Object Sender, EventArgs e)
    {
    FormsAuthentication.SignOut();
    Session.Abandon();
    Response.Redirect("index.aspx");
    }


如果您读了我的答案,那是我上次写的内容...


If you read my answer, that is what I wrote last time...


Session["Name"].Abandon();
这是错误.

会话"对象具有放弃"属性.个别物品则没有.我不确定您如何能够在单独引用后放弃Abandon,因为Visual Studio不会建议相同.尝试使用VS auto-intellegense,您将自己看到所有公开和可访问的内容.
Session["Name"].Abandon();
This is WRONG.

''Session'' object has ''Abandon'' property exposed to it. Individual items do not. I am not sure how you were able to put Abandon after individual reference as Visual Studio would not suggest the same. Try to use the VS auto-intellegense and you will see by yourself what all are exposed and accessible.


这篇关于错误-编译器错误消息:CS0117:“对象"不包含“放弃"的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆