温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

第七章   配置文件与网站部署

发布时间:2020-08-11 11:52:55 来源:网络 阅读:271 作者:彳亍的路人 栏目:编程语言

                           第七章    配置文件与网站部署

1.配置文件管理:

       (1).配置文件:①machine.config(有且只有一个)

                    ②web.config(每个站点都有一个web.config)

       (2)配置连接字符串:

           <connectionString>

               <add name="配置名" connectionString="server=.;database="数据库名";uid=sa;pwd=123456;"/>

           </connectionString>

           <appsettings>

               <add key="xxx" value="xxx"/>

           <appsettings>

       (3)使用连接字符串:

       private  static string connectionString = configurationManager.connectionString["配置名"].ToString();


       (4)数据库连接字符串的加密和解密:(vs命令提示)(加密和解密必须在同一机上完成)

      加密: aspnet_regiis.exe  -pef section physical_directory -prov provider

            或者

            aspnet_regiis.exe  -app section physical_directory -prov provider


      解密:aspnet_regiis.exe  -pdf section physical_directory -prov provider


2.自定义错误的配置

       <system.web>

           <customErrors mode="on" defaultRedirect="">

               <error statusCode="404" redirect=""/>

               <error statusCode="403"  redirect=""/>

           </customErrors>

        </system.web>

       defaultRedirect:指定发生错误时,浏览器重定向到页面的url

       mode:指定自定义错误的状态,on表示启用,off表示禁用,remoteonly表示其显示给远程计算机.

       statusCode:http的状态码,404表示未找到资源,403表示禁止访问.

       redirect:指定当前错误发生时,重定向到页面的url.

3.身份验证和授权配置:

   (1)身份验证:windows验证

               forms验证

               passport验证

               <system.web>

                   <authentication  mode="windows">

                   <authentication  mode="Forms">

                       <forms name="user" loginUrl="" timeout="60"></forms>

                   </authentication>

                 <authentication  mode="passport">

               </system.web>

   (2)授权

       <!

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


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI