♀如何在ASP.NET程序中创建IIS虚拟目录,并将该虚拟目录配置成应用程序?♂ 如题!里面可能还涉及到权限配置的问题,请有此开发经验的高人指教! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 const String constIISWebSiteRoot = "IIS://localhost/W3SVC/1/ROOT"; DirectoryEntry root = new DirectoryEntry(constIISWebSiteRoot); DirectoryEntry entry = new DirectoryEntry(constIISWebSiteRoot + "/" + virtualDirName); DirectoryEntry tbEntry = root.Children.Add(virtualDirName, "IIsWebVirtualDir"); //must be end with a '\' tbEntry.Properties["Path"][0] = virtualDirPath; tbEntry.Invoke("AppCreate",true); tbEntry.Properties["AccessRead"][0] = true; tbEntry.Properties["ContentIndexed"][0] = false; tbEntry.Properties["DefaultDoc"][0] = "index.asp"; tbEntry.Properties["AppFriendlyName"][0] = virtualDirName; tbEntry.Properties["AppIsolated"][0] = 2; tbEntry.Properties["AccessScript"][0] = true; tbEntry.Properties["DontLog"][0] = true; tbEntry.CommitChanges(); http://www.aspxboy.com/1252/default.aspx 或者 参考http://www.programfan.com/article/showarticle.asp?id=2455 楼上的代码我已经运行成功了:using System;using System.DirectoryServices;namespace BookTestClient{ // Class to test the book database: class Test { // Print the title of the book. // Execution starts here. static void Main() {const String constIISWebSiteRoot = "IIS://localhost/W3SVC/1/ROOT";string virtualDirName = "ttttt"; DirectoryEntry root = new DirectoryEntry(constIISWebSiteRoot); DirectoryEntry entry = new DirectoryEntry(constIISWebSiteRoot + "/" + virtualDirName); DirectoryEntry tbEntry = root.Children.Add(virtualDirName, "IIsWebVirtualDir"); //must be end with a '\' tbEntry.Properties["Path"][0] = @"c:/inetpub/wwwroot/ttttt"; tbEntry.Invoke("AppCreate",true); tbEntry.Properties["AccessRead"][0] = true; tbEntry.Properties["ContentIndexed"][0] = false; tbEntry.Properties["DefaultDoc"][0] = "index.asp"; tbEntry.Properties["AppFriendlyName"][0] = virtualDirName; tbEntry.Properties["AppIsolated"][0] = 2; tbEntry.Properties["AccessScript"][0] = true; tbEntry.Properties["DontLog"][0] = true; tbEntry.CommitChanges(); } }}请问服务器要怎么配置才有权限运行 DirectoryEntry tbEntry = root.Children.Add(virtualDirName, "IIsWebVirtualDir");楼上iuhxq(小灰) 的那段代码,我执行到这一句的时候就报告下列错误:拒绝访问。 说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Runtime.InteropServices.COMException: 拒绝访问。源错误: ASP.NET js 无法触发button的click事件 js 判断鼠标是否在某个控件上 如何把这种格式的XML读入到DataSet 页面的生存周期!!!! User.Identity.Name 是怎么回事啊 ? 是关于asp.net和orcale的问题 可能很少人注意到的问题 @_@ 救命~~~~ sql server 2005 根据已知表建表(动态表) 混淆器~~~~~~~~~~~~~~~~ 怎样把数据库的记录内容直接变成WEB页面 .net中在前台代码设置输入文本框非空的问题! 共享一下国外.net学习的网站,大家都是同志!
DirectoryEntry entry = new DirectoryEntry(constIISWebSiteRoot + "/" + virtualDirName); DirectoryEntry tbEntry = root.Children.Add(virtualDirName, "IIsWebVirtualDir"); //must be end with a '\'
tbEntry.Properties["Path"][0] = virtualDirPath;
tbEntry.Invoke("AppCreate",true);
tbEntry.Properties["AccessRead"][0] = true;
tbEntry.Properties["ContentIndexed"][0] = false;
tbEntry.Properties["DefaultDoc"][0] = "index.asp";
tbEntry.Properties["AppFriendlyName"][0] = virtualDirName;
tbEntry.Properties["AppIsolated"][0] = 2;
tbEntry.Properties["AccessScript"][0] = true;
tbEntry.Properties["DontLog"][0] = true;
tbEntry.CommitChanges();
using System.DirectoryServices;
namespace BookTestClient
{
// Class to test the book database:
class Test
{
// Print the title of the book.
// Execution starts here.
static void Main()
{
const String constIISWebSiteRoot = "IIS://localhost/W3SVC/1/ROOT";
string virtualDirName = "ttttt"; DirectoryEntry root = new DirectoryEntry(constIISWebSiteRoot);
DirectoryEntry entry = new DirectoryEntry(constIISWebSiteRoot + "/" + virtualDirName); DirectoryEntry tbEntry = root.Children.Add(virtualDirName, "IIsWebVirtualDir"); //must be end with a '\'
tbEntry.Properties["Path"][0] = @"c:/inetpub/wwwroot/ttttt";
tbEntry.Invoke("AppCreate",true);
tbEntry.Properties["AccessRead"][0] = true;
tbEntry.Properties["ContentIndexed"][0] = false;
tbEntry.Properties["DefaultDoc"][0] = "index.asp";
tbEntry.Properties["AppFriendlyName"][0] = virtualDirName;
tbEntry.Properties["AppIsolated"][0] = 2;
tbEntry.Properties["AccessScript"][0] = true;
tbEntry.Properties["DontLog"][0] = true;
tbEntry.CommitChanges();
} }
}
请问服务器要怎么配置才有权限运行
楼上iuhxq(小灰) 的那段代码,我执行到这一句的时候就报告下列错误:拒绝访问。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Runtime.InteropServices.COMException: 拒绝访问。源错误: