当前位置:编程学习 > C#/ASP.NET >>

关于web.config里的machineKey

RT,近期在看cookie的代码时候发现,如果在machineKey里设定了加密方式等等,系统怎么去取的web.config里的machineKey相关值。   

string configPath = Request.ApplicationPath;
//这里是我手动取的应用程序里的machineKey的路径,但我反编译了微软的代码,没有看到去取应用程序里的machineKey,而是取了系统(.net安装目录:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config)里的machineKey。很想知道这里是怎么做的,请知情者回复,谢谢。
          Configuration config = WebConfigurationManager.OpenWebConfiguration(configPath);
        MachineKeySection configSection =           (MachineKeySection)config.GetSection("system.web/machineKey");
        Console.WriteLine("File Path: {0}",          config.FilePath);
        Console.WriteLine("Section Path: {0}",          configSection.SectionInformation.Name);
        Console.WriteLine("ValidationKey: {0}",          configSection.ValidationKey);
        Console.WriteLine("DecryptionKey: {0}",          configSection.DecryptionKey);
        Console.WriteLine("Validation: {0}",          configSection.Validation);
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,