标签: asp.net-profiles

MVC-Mini-Profiler - Web窗体 - 无法找到/ mini-profiler-results

我正在尝试使用MVC-mini-profiler来处理webforms.

NUGET
我已经安装了Nuget包.

PM> Install-Package MiniProfiler
Run Code Online (Sandbox Code Playgroud)

团长
我有这个在我的网站的头部.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<%= MvcMiniProfiler.MiniProfiler.RenderIncludes() %>
Run Code Online (Sandbox Code Playgroud)

DAL
我在一个函数中使用它作为POC.这不在Global.asax中(我不知道是否需要.)

profiler = MiniProfiler.Start();

using (profiler.Step("Im doing stuff"))
{
   //do stuff here
}

MvcMiniProfiler.MiniProfiler.Stop();
Run Code Online (Sandbox Code Playgroud)

结果
<div class="profiler-results left"></div>在我的页面上呈现标记,但它是空的.

如果我查看chrome控制台,我会看到404试图找到:http://example.com/mini-profiler-results?id = 339d84a7-3898-429f-994b-64038462d59a&popup = 1

问题
我错过了让/ mini-profiler-results链接起作用的步骤吗?

回答
我标记为回答的响应让我认为它与我的配置无关(这是真的).我使用的是Umbraco 4.7.0.我不得不在web.config中的umbracoReservedUrls和umbracoReservedPaths中添加"〜/ mini-profiler-results".

asp.net profiling umbraco asp.net-profiles

16
推荐指数
1
解决办法
4547
查看次数

是否可以在不更新LastActivityDate的情况下访问配置文件?

在asp.net中(使用MVC,但这也经常发生)

Profile.GetProfile(username);
Run Code Online (Sandbox Code Playgroud)

将更新该用户的LastActivityDate.当其他人正在查看该用户的个人资料时,无意这样做.

在成员资格类中,您可以指定是否使用第二个参数更新此日期,如下所示:

Membership.GetUser(username, false); // doesn't update LastActivityDate
Membership.GetUser(username, true); // updates LastActivityDate
Run Code Online (Sandbox Code Playgroud)

无论如何在没有编写我自己的提供者的情况下在Profile提供者中做类似的事情?

asp.net asp.net-mvc asp.net-membership asp.net-profiles

11
推荐指数
1
解决办法
1502
查看次数

无法在自定义配置文件提供程序中加载类

我在C#中编写一个小型控制台应用程序,它引用了一个实现自定义.net Profile提供程序的自定义程序集.我已将以下部分添加到我的app.config文件中,该文件引用了自定义类和程序集.

<system.web>
<profile defaultProvider="MyCompanyProfileProvider" inherits="MyCompany.Web.User.GenericProfile" automaticSaveEnabled="false">
    <providers>
        <clear/>
        <add name="MyCompanyProfileProvider" connectionStringName="defaultDatabase" applicationName="/myApplication" type="MyCompany.Web.ProfileProvider, MyCompany.Web"/>
    </providers>
    <properties>
        <add name="JobRoleId" type="System.Int32"/>
        <add name="LastCompetencyId" type="System.Int32" defaultValue="0"/>
        <add name="MixSettings" type="System.Xml.XmlDocument"/>
    </properties>
</profile></system.web>
Run Code Online (Sandbox Code Playgroud)

但是,当我在调试模式下运行应用程序时,我得到以下错误,就好像它正在查看System.Web程序集而不是app.config文件中指定的那个.

无法从程序集'System.Web,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'加载类型'MyCompany.Web.User.GenericProfile'.

我有一个本地Web应用程序,也使用程序集和自定义配置文件提供程序,并且没有任何问题.我已经检查了引用的程序集被复制到输出目录.

有任何想法吗??

c# asp.net-profiles console-application

10
推荐指数
1
解决办法
3851
查看次数

我们可以在用户个人资料中保存KeyValuePair <K,V>吗?

[Serializable]
public class KeyValue : ProfileBase
{
    public KeyValue() { }

    public KeyValuePair<string, string> KV
    {
        get { return (KeyValuePair<string, string>)base["KV"]; }
        set { base["KV"] = value; }
    }            
}

public void SaveProfileData()
{
    KeyValue profile = (KeyValue) HttpContext.Current.Profile;
    profile.Name.Add(File);
    profile.KV = new KeyValuePair<string, string>("key", "val"); 
    profile.Save();
}   

public void LoadProfile()
{
    KeyValue profile = (KeyValue) HttpContext.Current.Profile;
    string k = profile.KV.Key;
    string v = profile.KV.Value;
    Files = profile.Name;          
}
Run Code Online (Sandbox Code Playgroud)

我试图保存KeyValuePair<K,V>在asp.net userprofile中,它也保存但是当我访问它时,它显示键和值属性null,任何人都可以告诉我我错在哪里?

LoadProfile()k和v中为空.

Web.config文件

<profile enabled="true" inherits="SiteBuilder.Models.KeyValue"> …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net-profiles asp.net-mvc-3

9
推荐指数
1
解决办法
614
查看次数

在.NET成员资格中使用List类型的配置文件属性

我正在开发一个需要提供身份验证以及角色和配置文件管理的C#Webservice.我需要每个配置文件都有一个List类型的属性.web.config中的配置文件部分如下所示:

<profile defaultProvider="MyProfileProvider" enabled="true">
  <providers>
    <remove name="MyProfileProvider"/>
    <add connectionStringName="MySqlServer"
      applicationName="MyApp"
      name="MyProfileProvider"
      type="System.Web.Profile.SqlProfileProvider" />
  </providers>
  <properties>
    <add name="Websites" type="System.Collections.Generic.List&lt;String&gt;" serializeAs="Binary"/>
  </properties>
</profile> 
Run Code Online (Sandbox Code Playgroud)

但是,当我启动webservice并尝试访问该属性时,它返回以下错误:

System.Configuration.ConfigurationErrorsException:尝试加载此属性的类型导致以下错误:无法加载类型'System.Collections.Generic.List <String>'.(C:\ Projects\MyProject\web.config第58行)---> System.Web.HttpException:无法加载类型'System.Collections.Generic.List <String>'.

有没有办法为此目的使用通用集合?

c# membership web-services asp.net-membership asp.net-profiles

7
推荐指数
1
解决办法
2194
查看次数

ASP.NET配置文件保存由旧值覆盖

我在网站上使用ASP.NET的配置文件功能.更新配置文件很奇怪!用户无法更新他/她自己的个人资料,无论是网站用户还是管理员,管理员都无法更新其他用户的个人资料.

在后端,调用Profile的save()后,SQL Server跟踪显示aspnet_Profile_SetProperties存储过程被调用两次.首先,使用旧值,使用旧值.第二次执行是在页面卸载后完成的.我的代码与事务无关.

为什么这么奇怪?

aspnet_regsql的安装是否存在问题,因为我已经安装了已卸载并再次安装它!?

web.config中

<authentication mode="Forms">
    <forms name="FormsAuthentication" loginUrl="~/Login.aspx" defaultUrl="~/Login.aspx" timeout="20"/>
</authentication>
<membership defaultProvider="CustSqlMembershipProvider">
    <providers>
        <add connectionStringName="connString" applicationName="/space_online" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" name="CustSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider"/>
    </providers>
</membership>
<roleManager enabled="true" defaultProvider="CustSqlRoleProvider">
    <providers>
        <add connectionStringName="connString" applicationName="/space_online" name="CustSqlRoleProvider" type="System.Web.Security.SqlRoleProvider"/>
    </providers>
</roleManager>
<anonymousIdentification cookieless="AutoDetect" enabled="true"/>
<profile defaultProvider="CustSqlProfileProvider" enabled="true">
    <providers>
        <add name="CustSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="connString" applicationName="/space_online"/>
    </providers>
    <properties>
        <add name="FirstName" type="System.String"/>
        <add name="LastName" type="System.String"/>
        <add name="Email" type="System.String"/>
        <group name="Address">
            <add name="Street" type="System.String"/>
            <add name="City" type="System.String"/>
            <add name="PostalCode" type="System.String"/>
        </group>
        <group name="Contact"> …
Run Code Online (Sandbox Code Playgroud)

c# asp.net sql-server-2005 asp.net-profiles

7
推荐指数
1
解决办法
3948
查看次数

如何在重定向之前加载新登录用户的配置文件

我启动了一个ASP.NET MVC 2项目,我正在构建自动生成的代码.

我遇到的问题是,在用户登录后,似乎新登录用户的配置文件未加载到该中HttpContext,因此我收到ProviderException消息"无法为匿名用户设置此属性"尝试在当前用户的配置文件中设置属性值时.

对于仅POST的LogOn操作,Visual Web Developer 2010 Express基本上生成:

    [HttpPost]
    public ActionResult LogOn(LogOnModel model, string returnUrl)
    {
        if (ModelState.IsValid)
        {
            if (MembershipService.ValidateUser(model.UserName, model.Password))
            {
                FormsService.SignIn(model.UserName, model.RememberMe);
        //...
Run Code Online (Sandbox Code Playgroud)

其中FormsService是类型控制器的属性FormsAuthenticationService(也是生成的):

public class FormsAuthenticationService : IFormsAuthenticationService
{
    public void SignIn(string userName, bool createPersistentCookie)
    {
        if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName");

        FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
    }

    public void SignOut()
    {
        FormsAuthentication.SignOut();
    }
}
Run Code Online (Sandbox Code Playgroud)

FormsService.SignIn(model.UserName, model.RememberMe)我假设新登录帐户的信息可以立即供控制器使用之后,但似乎并非如此.例如,如果我在profile.SetPropertyValue("MyProfileProperty", "test")下面添加对FormsService#SignIn的调用,那么我得到ProviderException"无法为匿名用户设置此属性".

如何将新登录用户的个人资料加载 …

c# visual-web-developer asp.net-membership asp.net-profiles asp.net-mvc-2

6
推荐指数
1
解决办法
4079
查看次数

配置文件对象+视图模型+更新用户配置文件MVC C#

问题: 由乔尔描述我创建了一个自定义配置文件对象这里.然后我使用Jeremy的方法(这里)扩展自定义配置文件,以允许我使用生成用户并设置这些值.然后,我创建了一个ViewModel来显示Memeberhip信息和配置文件信息,以便用户可以更新其会员信息(电子邮件)和配置文件信息.**视图显示我在视图中更新的信息中输入的所有字段,然后单击"保存",我收到以下错误

System.Configuration.SettingsPropertyNotFoundException:找不到设置属性"FirstName".**

这是我的自定义配置文件对象(模型):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Profile;
using System.Web.Security;


namespace NDAC.Models
{
    public class ProfileInformation : ProfileBase
    {
        static public ProfileInformation CurrentUser
        {
            get
            {
                if (Membership.GetUser() != null)
                {
                     return (ProfileInformation)(ProfileBase.Create(Membership.GetUser().UserName));
                }
                else
                {
                    return null;
                }
            }
        }

        public virtual string FirstName {
            get
            {

                return ((string)(base["FirstName"]));
            }
            set 
            {
                base["FirstName"] = value; Save();
            } 
        }
        public virtual string LastName {
            get 
            {
                return ((string)(base["LastName"])); …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc asp.net-profiles viewmodel c#-4.0

6
推荐指数
1
解决办法
5555
查看次数

使用成员资格数据在aspnet_profile表中存储其他数据

我在基于MVC2框架的项目中使用了带有OpenId实现的Membership API.除了用户名之外,我还需要在注册时将一些其他字段与用户相关联.

我不确定但是我认为asp.net中的Profile系统是为这种类型的要求而构建的.另外,我看到一个包含名为'aspnet_profile'的其他成员资格表的表.

我在应用程序web.config中添加了以下设置以启用配置文件:

<profile enabled="true">
      <properties>
        <add  name="FullName" allowAnonymous="false"/>

      </properties>

    </profile>
Run Code Online (Sandbox Code Playgroud)

如前所述,应用程序需要一些额外的数据与用户相关联,因此在使用Membership API创建用户时,我添加了几行代码以进入配置文件表

System.Web.Security.MembershipCreateStatus status = MembershipService.CreateUser(userModel.UserName, userModel.Password, userModel.UserName);

                   if (status == System.Web.Security.MembershipCreateStatus.Success)
                   {
                       FormsService.SignIn(userModel.UserName, true);
                       Session["Username"] = userModel.UserName;

                       dynamic profile = ProfileBase.Create(MembershipService.GetUser(userModel.UserName).UserName);
                       profile.FullName = userModel.UserFullName;
                       profile.Save();

                       RedirectToAction("Tech", "Home");



                   }
Run Code Online (Sandbox Code Playgroud)

但我没有看到数据库中的aspnet_profile表中添加了任何行.另外,我想询问这是否是添加其他数据以及默认成员资格数据的首选方式

.net asp.net asp.net-membership asp.net-profiles

6
推荐指数
1
解决办法
7027
查看次数

asp.net中的会话,缓存和配置文件有什么区别

我们经常在asp.net webform项目中使用session,cache和profile.我们经常在asp.net webform项目中将数据存储在会话,缓存和配置文件中,但我想知道何时应该在会话中存储数据,或者何时应该存储在缓存和配置文件中.缓存或配置文件的范围是什么.这两个会话特定的生命周期或应用程序具体.

假设我是否在会话1中存储缓存或配置文件中的任何数据,那么我是否可以从session2访问该数据.当我们应该在会话,缓存和配置文件中存储数据时,请引导我使用场景和示例.谢谢

session caching webforms asp.net-profiles

6
推荐指数
1
解决办法
9946
查看次数