我遇到了以下问题.
我运行以下代码
var binaryData = File.ReadAllBytes(pathToPfxFile);
var cert = new X509Certificate2(binaryData, password);
Run Code Online (Sandbox Code Playgroud)
在两个过程中.其中一个进程运行,LOCAL_SYSTEM并且此代码成功.另一个在IIS中在属于"Users"本地组的本地用户帐户下运行,在那里我得到以下异常:
System.Security.Cryptography.CryptographicException
Object was not found.
at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[] rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)
at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags)
at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData, String password)
//my code here
Run Code Online (Sandbox Code Playgroud)
所以我用Google搜索了一下,找到了一个类似问题的答案.我尝试启用LoadUserProfile应用程序池,现在可以正常运行.
问题是我没有得到我设置时会发生LoadUserProfile什么以及可能产生的后果.我的意思是,如果它是一个"好"的东西那么为什么它不是默认"开启",为什么它毕竟在那里?
当我LoadUserProfile在IIS池中设置时会发生什么,它会产生什么负面影响?
我目前的情况是我需要在IIS托管ASP.net/C# API的远程服务器上执行exe(它创建一个本地.txt文件).我创建了一个本地用户(比如userA)作为管理员来运行远程服务器中的Web服务,但是没有创建.txt文件.我已经检查并向userA授予必要的文件夹权限,并将用户添加到各个组中.有趣的是,如果我以远程系统中的userA身份登录,则exe会按预期执行.如果我退出然后它失败了.服务器是带有IIS 7的Win服务器2008.任何帮助将不胜感激.
更新:我已经解决了这个问题,并在此处发布了相关问题的答案和一些链接.简而言之,我需要在IIS应用程序池中设置"加载用户配置文件".
谢谢大家的贡献
我正在使用IIS 7.5运行Windows 7 - x64 Edition
我有一个简单的asp.net网站,我已经在其他版本的Windows和IIS上运行但是现在,在某些页面上它给了我以下错误
异常信息:异常类型:HttpParseException异常消息:对类型'System.Web.AspNetHostingPermission,System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的权限的请求失败.
堆栈跟踪:位于System.Web.UI.TemplateParser.ParseStringInternal(String text,Encoding fileEncoding)的System.Web.UI.TemplateParser.ProcessException(Exception ex)System.Web.UI.TemplateParser.ParseString(String text,VirtualPath virtualPath) ,编码fileEncoding)......
现在,当我在cassini下运行这个应用程序时,一切正常.我还能够弄清楚,无论我在哪里使用AjaxToolkit控件,这些页面都会抛出此错误.
有什么建议?
我刚刚将一个网站转换为一个Web应用程序项目,我收到此错误:
System.Security.SecurityException: Request for the permission of type
'System.Web.AspNetHostingPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?IIS7上的其他一切运行正常.该应用程序需要完全信任,我在web.config中设置了该设置.我是否需要在IIS中的某处提供完全信任访问权限?
谢谢!