配置文件与网站部署

在ASP.NET 的配置文件的方式: machine.config   和web.config 都是基于XML的格式

 machine.config:

        用于整个计算机所有应用程序的配置  -->服务器配置文件 修改后将影响所有本机应用程序

web.config:

        默认创建在网站的根目录下,在站点所有文件中都可以使用

链接字符串的加解密:

   找到vs的命令提示符   命令行工具(aspnet_regiis.exe)

aspnet_regiis.exe  -pef "connectionStrings" "文件的路径(E:WEBshow)"  加密

aspnet_regiis.exe  -pdf "connectionStrings" "文件的路径(E:WEBshow)"  解密

   注意:   加密解密必须在同一台机器上进行

             加密后的链接字符串可以直接使用

             站点路径最好不要有中文

自定义错误的配置:

   在web.config文件的<system.web>中配置

eg:

<customErrors  mode="on" defaultRedirect="~/error/error.htm">

     <error  statusCode="404" redirect="~/error/404.htm">

</customErrors>

statusCode:HTTp状态码  

 身份验证和授权配置

  1,身份验证:

        Windows  默认值  验证性高,但只能用于Windows平台 要求访问者在文本服务器只有一个账号

                    <system.web>

                             <authentication mode="Windows">

                        </system.web>  

 Forms特定网 页      必须从登陆页面登陆

        <system.web>

               <authentication mode="Forms">

                                //Cookie名                         //有效时间

                 <forms name="user" loginUrl="~/.." timeout="60" ></froms>

               </authentication>

           </system.web>  

passport网站人员的集中式商业验证服务  单点登陆,需要付费 跨域,跨站点

   <system.web>

          <authentication mode="passport">

      </system.web>  

 None 无验证

 授权

   <?xml version="1.0" ?>

   <configuration>

         <system.web>

               <authorization>

                 <!--禁止匿名用户-->

                      <deny   users="?">

                    <!--允许登陆-->

                       <allow  roles="admin">

                 </authorization>

           /<system.web>

    </ configuration>

发布时,选择Release 表示程序已经做完,不能被修改

           选择Debug 调试发布.跨域更改

           

原文地址:https://www.cnblogs.com/shuaif/p/3485552.html