C# 请求“System.Web.AspNetHostingPermission”类型的权限
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13603613/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Request for the permission of type 'System.Web.AspNetHostingPermission"
提问by MARKAND Bhatt
I am facing a problem for running my website.
我在运行我的网站时遇到问题。
I have developed the website and when i hit F5 to view the results i am presented with this error
我已经开发了网站,当我按 F5 查看结果时,我看到了这个错误
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
描述:应用程序试图执行安全策略不允许的操作。要授予此应用程序所需的权限,请联系您的系统管理员或在配置文件中更改应用程序的信任级别。
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
异常详细信息:System.Security.SecurityException:请求类型为“System.Web.AspNetHostingPermission、System、Version=2.0.0.0、Culture=neutral、PublicKeyToken=b77a5c561934e089”的权限失败。


How can i solve this problem.
我怎么解决这个问题。
回答by MMK
you can run the following command to Grant FullTrust to remote share:
您可以运行以下命令将 FullTrust 授予远程共享:
C:\Windows\Microsoft.NET\Framework\v2.0.50727>caspol.exe -m -ag 1 -url "file:////\yourcomputername\yoursharename*" FullTrust -exclusive on
C:\Windows\Microsoft.NET\Framework\v2.0.50727>caspol.exe -m -ag 1 -url "file:////\yourcomputername\yoursharename*" FullTrust -exclusive on
Hope this helps.
希望这可以帮助。
回答by Albin Varghese
I face the same problem, then I realised that I was running the solution from a remote folder. Copy the necessary file to the local folder will solve the issue. But make sure that your folder have the full permission
我遇到了同样的问题,然后我意识到我是从远程文件夹运行解决方案的。将必要的文件复制到本地文件夹即可解决问题。但请确保您的文件夹具有完全权限
回答by randyh22
I tried all of the solutions posted here and a number of other places and nothing worked for me. I had my project located on a network drive which worked until I tried to use the AjaxControlToolkit 2.0 in my project. Apparently, something about permissions on the network drive would not allow the controls in the toolkit to run. I moved my project back to my local hard drive and it all started working.
我尝试了这里和其他一些地方发布的所有解决方案,但没有任何效果对我有用。我的项目位于网络驱动器上,直到我尝试在我的项目中使用 AjaxControlToolkit 2.0。显然,网络驱动器上的权限不允许工具包中的控件运行。我将我的项目移回我的本地硬盘驱动器,一切都开始工作了。
回答by akokani
This error usually happens if you Map your application folder on Network Drive or open Solution file from UNC Path. somthing like this:
如果您在网络驱动器上映射应用程序文件夹或从 UNC 路径打开解决方案文件,通常会发生此错误。像这样的东西:
Invalid Example: \\my-server\my-project
无效示例: \\my-server\my-project
Try to open your solution from direct path
尝试从直接路径打开您的解决方案
Valid Example: C:\Project\MyProject
有效示例:C:\Project\MyProject
You can also make change to your privilege of App Pool Identitybut it's not recommanded:
您也可以更改您的App Pool Identity权限,但不建议这样做:
Web Server (IIS) > App Pool Identity > Advance Settings > Set Identity as Network Service
Web 服务器 (IIS) > 应用程序池标识 > 高级设置 > 将标识设置为 网络服务
回答by PhillyNJ
For what its worth, I found that the AjaxControlKit.dllon the deployed server was blocked. To resolve this, I copied over the dll to a new folder then copied and pasted in the binfolder. I guess .net doesn't like a dll being copied over directly to the web folder
无论如何,我发现AjaxControlKit.dll部署的服务器上的 被阻止了。为了解决这个问题,我将 dll 复制到一个新文件夹,然后复制并粘贴到该bin文件夹中。我猜 .net 不喜欢将 dll 直接复制到 web 文件夹
回答by donstack
the one shot solution worked for me was to set the App Pool Identity(Advance Settings) to Network Service
对我有用的一次性解决方案是将应用程序池标识(高级设置)设置为网络服务
回答by Neeraj Gopal
The best way to resolve this issue is Run the Visual Studio as "Administator". Right click on the Visual Studio icon and select "Run as Administrator".
解决此问题的最佳方法是以“管理员”身份运行 Visual Studio。右键单击 Visual Studio 图标并选择“以管理员身份运行”。
Once you open Visual Studio with Full admin rights, you will be able access the page without any issues.
以完全管理员权限打开 Visual Studio 后,您将能够毫无问题地访问该页面。
回答by RSB
Try to set "Load User Profile" value of your application pool to "True". It worked for me.
尝试将应用程序池的“加载用户配置文件”值设置为“True”。它对我有用。
回答by PhillyNJ
I have had this error and it seems to be a generic error. As there are several answers to this issue, I am going to add mine. Republishing the website on the remote server seems to fix it for me.
我遇到了这个错误,它似乎是一个通用错误。由于这个问题有几个答案,我将添加我的答案。在远程服务器上重新发布网站似乎为我解决了这个问题。
回答by Shrink
I had this problem as well but have not seen this particular solution mentioned anywhere.
我也有这个问题,但没有看到任何地方提到的这个特定的解决方案。
After checking permissions for the IIS user, the user for Impersonation, and granting Full Trust to the application, and still getting the error, I installed Procmon.exe on the server running IIS and noticed that IIS was attempting to access some Framework64 files for the offending website. I inspected the application pool advanced settings and discovered that "enable 32-bit applications" was set to false. Changing this setting to true proved to be the correct action. Life is good.
在检查了 IIS 用户、模拟用户的权限并授予应用程序完全信任后,仍然出现错误,我在运行 IIS 的服务器上安装了 Procmon.exe 并注意到 IIS 试图访问一些 Framework64 文件以违规网站。我检查了应用程序池高级设置,发现“启用 32 位应用程序”设置为 false。将此设置更改为 true 被证明是正确的操作。生活很好。

