漫漫技术人生路

C#

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

   <system.web>
    <httpModules>
      <add name="Page" type="ns.class"></add>
    </httpModules>
  </system.web>

namwspace ns
{
  class class:IhttpModule
{
    public void dispose:IhttpModule.dispose
{

}


   public void init(httpApplication xontext):IhttpModule.init
{

}

}

}
----------------------------------------------------------------
<sessionState mode="Off"/>关闭会话状态
〈pages enableSessionState="ReadOnly"/>设置会话状态为只读
编译缓存的是中间代码在磁盘上
----------------------------------------------------------
输出缓存,借助于缓存整个页面
<%@ OutputCache Duration="30" VaryByParam="none"%>
OutputCache 指令告诉asp/net,一旦已经创建页面输出,就将其存储在缓存中
VaryByParam属性表示外部影响是否会影响如何缓存页面.,none表示不影响,也只缓存一个副本,type意味着将针对变量的每个不同值缓存页面

副本
片段缓存
<%@ Control OutputCache Duration="30" VaryByParam="none"%>只缓存用户控件

缓存后替换

<%@ OutputCache Duration="30" VaryByParam="none"%>
<asp:Substitution ID="sub1" runat="server" MethodName="sub" />
MethodName指示一个函数,返回替换到缓存页面中的数据字符串
  ---------------------
使用存储过程
<asp:sqldatasource>
connectionstring=<%$connectionStrings:dd%>
SelectedCommand="prodd"
selectedCommandType="StoredProcedure"
</asp:sqldatasource>
---------------------------------------------------------
protected void bt_Click(object sender, EventArgs e)
    {
        //更新配置文件 Profile.Name=(textBox)dd.fincontol[""].text
        //server.Transfer方法在请求指定的页面时运行代码  server.Transfer(siteMap.CurrentNode.url)
        //server.Transfer方法停止当前页面的执行,并且在指定的页面上运行内容在这种情况下,希望再次加载当前页面从而刷新页面的当前试图
    }
    protected void logicView_ViewChanged(object sender, EventArgs e)
    {
        //更新配置文件属性的设置
    }

 

<asp:LoginView ID="logicView" runat="server" OnViewChanged="logicView_ViewChanged">
     <LoggedInTemplate>
         you are logged in
     </LoggedInTemplate>
     <RoleGroups>
         <asp:RoleGroup Roles="总经理">
             <ContentTemplate>
              <p>FFFFF总经理角色看到的页面</p>
                 hao rolegroup
                 <p><asp:Button ID="bt" runat="server" Text="bt" OnClick="bt_Click" /></p>
             </ContentTemplate>
         </asp:RoleGroup>
         <asp:RoleGroup Roles="员工">
             <ContentTemplate>
                 员工看到的页面
             </ContentTemplate>
         </asp:RoleGroup>
         <asp:RoleGroup Roles="部门主管">
             <ContentTemplate>
                 部门主管看到的
             </ContentTemplate>
         </asp:RoleGroup>
     </RoleGroups>
     <AnonymousTemplate>
         you are not logged
         <span>DJKLASJGKLJGLREKJ</span>
     </AnonymousTemplate>
 
 </asp:LoginView>

  <system.web>
    <profile enabled="true">
      <properties>
        <add name="userId" type="System.Boolean"></add>
        <!--
        也可以是自定义类型
        <add name="cart" serializaAs="Binary" type="Wrox.commerce.shoopingCart" allowAnonymous="true"/>
        在页面中使用profile.Name="Chris Hart"
        -->
      </properties>
     
    </profile>
   
  </system.web>

 <location path="default.aspx">

    <system.web>

      <authorization>
        <allow roles="员工" />
      </authorization>
      <!--如果加上
    <siteMapNode url="text/default.aspx" roles="员工,部门主管">
    这样将使得部门主管能够看到连接但不能访问连接
    说明web.config中的授权优先级高
    IsInRole()方法用于在代码中使用角色
    public readonly double  member
    {
      get{
            if(httpContext.current.user.IsInRole("员工")
            {
                return subtotal * ff
                string s=String.Format("sub:{0,35:c}",ddvar);
               
            }
            else{
              return 0;
            }
         }
   
    }
    httpContext.Current.User.IsInRole("员工")的调用
    第一次用上面的
    下一次就只要用Context.user.IsInRole("员工")
    两次调用间有区别
    -->
    </system.web>
  </location>

  <location path="test2.aspx">
    <!--
    假设test2是个文件夹,那可以连接自身
    role控制的是文件夹
    -->
    <system.web>

      <authorization>
        <allow roles="总经理" />
        <allow roles="员工" />
      </authorization>
    </system.web>
  </location>

posted on 2006-10-17 11:39  javaca88  阅读(315)  评论(0编辑  收藏  举报