IIS教程:因权限问题被拒绝访问的解决方案

 写了一个类IISAdmin,负责建立、设置、删除虚拟目录,发现在web中调用,遇到权限问题,解决方法如下(转载):

 下面代码在ASP.NET中,会因权限问题被拒绝访问。 

以下为引用的内容:
System.DirectoryServices.DirectoryEntry directoryEntry; 
directoryEntry = new System.DirectoryServices.DirectoryEntry("IIS://localhost/w3svc/1"); 
directoryEntry.Invoke("Start", new object[] { }); 错误:拒绝访问。 
异常详细信息: System.UnauthorizedAccessException: 拒绝访问。 解决方法 
修改web.config文件 
<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.web> 
       <identity impersonate="true" userName="administrator" password="1q2w3e4r"/> 
    </system.web> 
</configuration>

 在ASP.NET里面使用COM对象的时候,会被拒绝访问。

 可以在web.config里面添加下面代码解决

以下为引用的内容:
<identity impersonate="true" userName="username" password="password"/>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值