ASP.NET 2.0個人化配置(profile)__.net

來源:互聯網
上載者:User
  ASP.NET 2.0個人化配置(profile)

 

為每個使用者儲存配置資訊
強型別 長期儲存   支援匿名使用者
定義配置( profile )

 

<?xml version="1.0"?>

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <appSettings/>
    <connectionStrings>
        <add name="Northwind" connectionString="Server=localhost;Integrated Security=True;Database=Northwind" providerName="System.Data.SqlClient"/>
    </connectionStrings>
    <system.web>

        <anonymousIdentification enabled="true" />
        <profile>   //定義配置(profile)
            <properties>
                <add name="Theme" allowAnonymous="true" />
                <add name="LastVisit" type="System.DateTime" allowAnonymous="true" />
            </properties>
        </profile>
<!--
        <webParts>  //定義配置(webParts)
            <personalization defaultProvider="AspNetSqlPersonalizationProvider"/>
        </webParts>
-->
        <!-- 
            Set compilation debug="true" to insert debugging symbols into the compiled page.
            Because this affects performance, set this value to true only during development.
        -->
        <compilation debug="true">
            <expressionBuilders>
                <add expressionPrefix="Version" type="VersionExpressionBuilder"/>
            </expressionBuilders>
        </compilation>
        <!--
            The <authentication> section enables configuration of the security authentication
            mode used by ASP.NET to identify an incoming user. 
        -->
        <authentication mode="Windows"/>
        <!--
            The <customErrors> section enables configuration of what to do if/when an unhandled
            error occurs during the execution of a request.  Specifically, it enables developers
            to configure html error pages to be displayed in place of a error stack trace.
        -->
        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <!-- 
            <error statusCode="403" redirect="NoAccess.htm"/>
            <error statusCode="404" redirect="FileNotFound.htm"/>
        -->
        </customErrors>
    </system.web>
</configuration>


使用配置(profile)
//increment the current user's post cout
profile.posts = profile.posts+1;
// update the current user's last post date
profile.lastpost = datetime.now;

個人化資料將存入資料庫

介紹
Microsoft ASP.NET 2.0支援被稱為Profile的新對象,它可以自動在多個Web應用程式的訪問之間儲存使用者資訊。一個User Profile中可以儲存各種類型的資訊,這些資訊既可以是簡單的string和integer類型,也可以是複雜的自訂類型。例如,你可以儲存使用者的姓、購物籃、使用者屬性或網站使用方式統計。
本文中,你將學習如何在一個應用中定義user profile。我們也會向你示範如何配置使用不同provider的profile。最後,你將學習如何管理和產生user profile的報告。

User Profiles總攬
Profile 對象與Session對象十分相似,但是更好用一些。與Session相似的地方在於,Profile是相對於一個特定的使用者的,也就是說,每個Web應用程式的使用者都有他們自己的profile對象。與Session不同的是,Profile對象是持久對象。如果你向

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.