在网络共享或 Intranet 项目上编译网站时,请求类

Request for the permission of type #39;System.Web.AspNetHostingPermission#39; failed when compiling web site on a Network Share or Intranet Project(在网络共享或 Intranet 项目上编译网站时,请求类型“System.Web.AspNetHostingPermission的权限失败)

本文介绍了在网络共享或 Intranet 项目上编译网站时,请求类型“System.Web.AspNetHostingPermission"的权限失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 Windows 7 一段时间了,但自从我升级后,我不必使用特定的旧版 Intranet 应用程序.不幸的是,此应用程序被设置为托管在 Intranet 服务器上的 ASP.NET 网站项目.当我在 Visual Studio 2008 中打开网站并尝试调试它时,我收到以下编译器错误:

请求类型为System.Web.AspNetHostingPermission"的权限失败

要在 Windows Vista 计算机上解决此问题,我会将本地 Intranet 的计算机的 .NET 安全配置信任级别更改为完全 (此处概述了修复).我相信这个配置实用程序依赖于 mscorcfg.msc,从一些粗略的研究来看,它似乎是 .NET 2.0 SDK 的一部分.我已尝试按照此 Microsoft 支持文章中的说明运行以下命令,但无济于事.

<前>驱动器:WINDOWSMicrosoft.NETFrameworkv2.0.50727caspol.exe -m -ag 1 -url"file:////\计算机名共享名*" FullTrust -exclusive on

目前,我的机器上安装了以下 .NET、ASP.NET 和 .NET SDK 组件

  • Microsoft .NET Compact Framework 2.0 SP2
  • Microsoft .NET Compact Framework 3.5
  • Microsoft .NET Framework 4 客户端配置文件
  • Microsoft .NET Framework 4 扩展
  • Microsoft .NET Framework 4 多目标包
  • 微软 ASP.NET MVC 1.0
  • 微软 ASP.NET MVC 2
  • Microsoft ASP.NET MVC 2 - Visual Studio 2008 工具
  • Microsoft ASP.NET MVC 2 - Visual Studio 2010 工具
  • 适用于 Visual Studio 2008 .NET Framework 工具的 Microsoft Windows SDK - enu
  • 适用于 Visual Studio 2008 标头和库的 Microsoft Windows SDK
  • 适用于 Visual Studio 2008 SDK 参考程序集和 IntelliSense 的 Microsoft Windows SDK
  • 适用于 Visual Studio 2008 SP1 工具的 Microsoft Windows SDK
  • 适用于 Visual Studio 2008 SP1 Win32 工具的 Microsoft Windows SDK
  • 适用于 Windows Server 2008 的 Microsoft Windows SDK (6001.18000.367)

我需要安装 .NET 2.0 SDK 吗?我是否错误地发出了 caspol 命令?还有什么我遗漏的吗?

解决方案

经过一些额外的挖掘,我发现了 Aaron Stebner 的一篇博客文章,内容涉及 有关.NET Framework 2.0 配置工具设置的详细信息.Stebner 详细说明了如何从 .NET 可再发行组件中删除配置实用程序并仅将其放置在 SDK 中.几年前这没什么大不了的,但现在社区依赖较新的 SDK 并且只安装框架的可再发行版/精简版,我们无法访问 .NET Framework 2.0 配置工具.

微软的官方回答是使用代码访问安全策略配置安全策略工具 (Caspol.exe).不幸的是,这个命令行实用程序对我不起作用.但是,我不排除用户错误导致失败的原因.

最终,Stebner 解决了我的问题,因为他提供了一个 配置工具的安装程序.一旦我安装了配置实用程序,我就可以按照 DotNetsp.WebSlacker 文章中概述的步骤进行操作.使用 Visual Studio 2005 访问网络或 Intranet 项目时,我已将其解释为以下步骤.

要更改本地计算机的 .NET 安全设置,请转到

开始 > 控制面板 > 管理工具 > Microsoft .NET Framework 2.0 配置

完全展开我的电脑并选择运行时安全策略.在右侧,选择调整区域安全.保留默认选项(更改此计算机)并点击下一步.选择Local Intranet并将信任级别更改为完全信任.然后选择下一步,然后选择完成.重新启动 Visual Studio,你应该一切都准备好了.

I have been using Windows 7 for a while but have not had to work with a particular legacy intranet application since my upgrade. Unfortunately, this application is setup as an ASP.NET Website project hosted on an intranet server. When I have the website open in Visual Studio 2008 and try to debug it, I receive the following compiler error:

Request for the permission of type 'System.Web.AspNetHostingPermission' failed

To resolve this issue on Windows Vista machines, I would change the machine's .NET Security Configuration trust level to full for the local intranet (fix outlined here). I believe this configuration utility relied upon the mscorcfg.msc which from some cursory research appears to be apart of the .NET 2.0 SDK. I have tried to follow the instructions from this Microsoft Support article running the command below to no avail.

Drive:WINDOWSMicrosoft.NETFrameworkv2.0.50727caspol.exe -m -ag 1 -url
"file:////\computernamesharename*" FullTrust -exclusive on

Presently, I have the following .NET, ASP.NET, and .NET SDK components installed on my machine

  • Microsoft .NET Compact Framework 2.0 SP2
  • Microsoft .NET Compact Framework 3.5
  • Microsoft .NET Framework 4 Client Profile
  • Microsoft .NET Framework 4 Extended
  • Microsoft .NET Framework 4 Multi-Targeting Pack
  • Microsoft ASP.NET MVC 1.0
  • Microsoft ASP.NET MVC 2
  • Microsoft ASP.NET MVC 2 - Visual Studio 2008 Tools
  • Microsoft ASP.NET MVC 2 - Visual Studio 2010 Tools
  • Microsoft Windows SDK for Visual Studio 2008 .NET Framework Tools - enu
  • Microsoft Windows SDK for Visual Studio 2008 Headers and Libraries
  • Microsoft Windows SDK for Visual Studio 2008 SDK Reference Assemblies and IntelliSense
  • Microsoft Windows SDK for Visual Studio 2008 SP1 Tools
  • Microsoft Windows SDK for Visual Studio 2008 SP1 Win32 Tools
  • Microsoft Windows SDK for Windows Server 2008 (6001.18000.367)

Do I need to install the .NET 2.0 SDK? Am I issuing the caspol command incorrectly? Is there something else that I am missing?

解决方案

After some additional digging I came across a blog post by Aaron Stebner covering Details about setup for the .NET Framework 2.0 configuration tool. Stebner details how the Configuration Utility was removed from the .NET redistributable and placed only in the SDK. Not a big deal a few years ago but now that the community relies upon newer SDKs and only installs the redistributable / compact versions of the framework we have lost access to the .NET Framework 2.0 Configuration Tool.

The official answer from Microsoft is to Configure Security Policy Using the Code Access Security Policy Tool (Caspol.exe). Unfortunately, this command line utility did not work for me. I however, do not rule out user error as to why it failed.

Ultimately, Stebner solved my issue because he provides an installer for the configuration tool. Which once I had the configuration utility installed allowed me follow the steps outlined in th DotNetSlackers article System.Web.AspNetHostingPermission when Accessing Network or Intranet Projects using Visual Studio 2005 which I have paraphrased into steps below.

To change the local machine's .NET Security Settings goto

Start > Control Panel > Administrative Tools > Microsoft .NET Framework 2.0 Configuration

Fully expand My Computer and select Runtime Security Policy. On the right, choose Adjust Zone Security. Leave the default option (Make changes to this computer) and hit next. Choose Local Intranet and change the trust level to Full Trust. Then choose Next and then Finish. Restart Visual Studio and you should be all set.

这篇关于在网络共享或 Intranet 项目上编译网站时,请求类型“System.Web.AspNetHostingPermission"的权限失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在网络共享或 Intranet 项目上编译网站时,请求类

基础教程推荐