zoukankan      html  css  js  c++  java
  • 文件配置

    配置文件和网站的部署

    配置文件的类型:
        machine.config:对计算机所有的应用程序的配置。
        Web.config:对网站的部署。


    数据连接字符串的配置

    <configuration>
     <system.web>
     <connectionStrings>
      <add name="mysql" connectionString="server=.;database=mydb;uid=sa;pwd=123456;" />
     </connctionStrings>
     </system.web>
    </configuration>
    


    在项目中使用连接字符串

    private static string strConn=ConfigurationManager.ConnectionString["mysql"].ToString();
    


    数据库连接字符串的加密和解密
           使用APS.NET提供的命令行工具aspnet_regiis.exe

            加密指令:aspnet_regiis -pef section physical_directory

            解密指令:aspnet_regiis -pdf section phycical_directory

            其中section表示要加密或解密的配置节,physical_directory指定站点的物理路径


    数据库的连接字符串加密和解密时应注意地方:
        <1>、加密后的连接字符串可以直接使用,
        <2>、加密和解密必须在同一计算机中进行


    自定义配置

    <configuration>
            <system.web>
                     <customErrors mode="on" defaultRedirect="~/error/error.aspx">
                             <error statusCode="404" redirect="~/error/pagenotfound.aspx" />
                     </customErrors>
             </system.web>
    </configuration>
    


    //身份验证和授权的配置
    ASP.NET的身份验证类型
     <1>windows
     <2> forms:为验证请求被重定向一个特定的页面,该网页会从用户哪里得到凭证,并把凭证提交给应用程序用于身份验证
     <3> passport:微软提供网站开发人员的集中式商业验证服务
     <4> none:无验证,允许匿名访问

    windows验证的配置方式:

    <system.web>
              <authentication mode="windows" />
    </system.web>
    

    Forms验证的配置方式:

    <system.web>
            <authentication mode="forms">
                   <forms name="user' loginUrl="~/admin/login.aspx"> </forms>
            </authentication>
    </system.web>
    

    passport验证的配置方式:

    <system.web>
                <authentication mode="passport" />
    </system.web>
    


    授权

    <system.web>
             <authorization>
             <!--禁止匿名用户-->
             <deny users="?">
             <!--允许管理员角色-->
             <allow roles="admin">
             </authorization>
    </system.web>
    


    如果使用表单验证,需要对用户登陆和注销做一些操作

    登陆页面可编写代码如下:

    //...登陆成功后...
    string strRedirect=Requst["returnRul"];
    
    //给用户发放凭证
    System.Web.Security.FormsAuthentication.SetAuthCookie(user.Nama,true);
    
    if(strRedirect!=null)
    {
            Response.Redirect(strRedirect);
    }
    //......
    
    删除凭证
    System.Web.Security.FormsAuthentication.SignOut();
    


     

  • 相关阅读:
    iOS --有行距的图文混排
    iOS 。开发之指纹识别功能
    ios UICollectionView reloadData无法更新的奇怪问题。
    ios
    ios
    iOS --随机打乱一个数组的顺序 获得一个新的数组
    PYTHON -转载,获取淘宝数据01
    ios . -- UICollectionView --cell 自适应
    Web 四种常见的POST提交数据方式
    Objective-C 谈谈深浅拷贝,copy和mutable copy都不是完全拷贝
  • 原文地址:https://www.cnblogs.com/fengyu-2/p/3484420.html
Copyright © 2011-2022 走看看