“HttpContext.Current.Profile”引发Configuration.ConfigurationErrorsException类型的异常
时间:2011-12-25
来源:互联网
以下是Web.config代码:
C# code
<profile enabled="true" inherits="Web.MyProfileCommon"> <properties> <add name="UserName" allowAnonymous="false" type="string" /> <add name="ShoppingCart" allowAnonymous="false" type="BLL.CartManager"/>//这行是72行 </properties> </profile>
下面是我自己写的Web.MyProfileCommon类(用的是Web application):
C# code
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Profile; using BLL; namespace Web { public class MyProfileCommon : System.Web.Profile.ProfileBase { public MyProfileCommon() //无参构造函数 { } [SettingsAllowAnonymous(false)] public string UserName { get { return base["UserName"].ToString(); } set { base["UserName"] = value; } } [SettingsAllowAnonymous(false)] public CartManager ShoppingCart { get { return (CartManager)base["ShoppingCart"]; } set { base["ShoppingCart"] = value; } } } }
我在code-behind里面这里写了一个全局定义:
C# code
public partial class ShoppingCart : System.Web.UI.Page { MyProfileCommon Profile = (MyProfileCommon)HttpContext.Current.Profile;//这样定义了一个Profile protected void Page_Load(object sender, EventArgs e) {
然后调试的时候出错了,Profile为null,(未将对象引用设置到对象的实例)
错误信息:
HttpContext.Current.Profile “HttpContext.Current.Profile”引发了“System.Configuration.ConfigurationErrorsException”类型的异常 System.Web.Profile.ProfileBase {System.Configuration.ConfigurationErrorsException}
base: {"已定义此配置文件属性。 (F:\\网上购物系统\\StarBookShop\\Web\\web.config line 72)"} System.Exception {System.Configuration.ConfigurationErrorsException}
请高手指点迷津啊。。小弟刚学用Profile保存信息,现在被问题卡住了,找不到办法解决,求帮助!
作者: q380472335 发布时间: 2011-12-25
顶啊顶啊..求帮助
作者: q380472335 发布时间: 2011-12-25
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28