kk-001 2023-04-15 12:33 采纳率: 0%
浏览 26
已结题

当前上下文中不存在名称“Profile,如何解决?

error CS0103: 当前上下文中不存在名称“Profile”

img

但是在web.config文件已经定义了profile

<configuration>
  <connectionStrings>
    <add name="MyPetShopConnectionString" connectionString="Data Source=(localdb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\MyPetShop.mdf;Initial Catalog=MyPetShop;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
    <system.web>
        <compilation debug="true" targetFramework="4.0">
            <assemblies>
                <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            </assemblies>
        </compilation>
        <anonymousIdentification enabled="true" />
        <profile>
            <properties>
                <group name="Cart">
                    <add name="ProId" type="System.Collections.ArrayList" allowAnonymous="true" />
                    <add name="Proname" type="System.Collections.ArrayList" allowAnonymous="true" />
                    <add name="Qty" type="System.Collections.ArrayList" allowAnonymous="true" />
                    <add name="ListPrice" type="System.Collections.ArrayList" allowAnonymous="true" />
                    <add name="TotalPrice" allowAnonymous="true" />
                    </group>
                </properties>
            </profile>
                </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
</configuration>
  • 写回答

1条回答 默认 最新

  • _东_ 2023-04-17 15:08
    关注

    你试试这个呢:

    List<String> lists = (List<String>)HttpContext.Current.Profile.GetProfileGroup("Cart").GetPropertyValue("ProName");
    

    这里有一篇不错的博客,你可以简单参考:

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 3月8日
  • 修改了问题 4月15日
  • 创建了问题 4月15日

悬赏问题

  • ¥20 虚幻UE引擎如何让多个同一个蓝图的NPC执行一样的动画,
  • ¥15 fluent里模拟降膜反应的UDF编写
  • ¥15 MYSQL 多表拼接link
  • ¥15 关于某款2.13寸墨水屏的问题
  • ¥15 obsidian的中文层级自动编号
  • ¥15 同一个网口一个电脑连接有网,另一个电脑连接没网
  • ¥15 神经网络模型一直不能上GPU
  • ¥15 pyqt怎么把滑块和输入框相互绑定,求解决!
  • ¥20 wpf datagrid单元闪烁效果失灵
  • ¥15 券商软件上市公司信息获取问题