VS2005打包,制作Web安装程序时,如何建立IIS站点? 参考 http://www.aspxboy.com/private/4339/default.aspx 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.aspxboy.com/private/2676/default.aspxhttp://www.aspxboy.com/private/5200/default.aspxhttp://www.aspxboy.com/2256/default.aspx 谢谢 xiahouwen(武眉博<活靶子.NET>) 不过这些好像都是对虚拟目录的操作,而不是对站点的操作 下面的代码如果放到单独的项目里,就可以在IIS上建立站点(把Install(...)的内容放到一个按钮事件里).现在放在"安装项目"的一个类里,却是怎么也不能建立站点有谁做过这一块的,帮助一下using System;using System.IO;using System.DirectoryServices;using System.Reflection;using System.Data;using System.Data.SqlClient;using System.Configuration.Install;using System.Management;using System.Collections;using Microsoft.Win32;using System.Collections.Specialized;namespace SetupClassLibrary{ public partial class MyInstaller : Installer { static DirectoryEntry iisDE = new DirectoryEntry("IIS://localhost/W3SVC"); public MyInstaller() { } #region Install 安装 public override void Install(IDictionary stateSaver) { base.Install(stateSaver); string serverComment = "MyWebSetup"; string defaultVrootPath = this.Context.Parameters["targetdir"]; if (defaultVrootPath.EndsWith(@"\")) { defaultVrootPath = defaultVrootPath.Substring(0, defaultVrootPath.Length - 1); } int Port = 9998; CreateNewIIsWebServer(serverComment, defaultVrootPath, Port); } #endregion public void CreateNewIIsWebServer(string webServerName, string path, int port) { int siteID = GetWebSiteInfo(port); using (DirectoryEntry site = (DirectoryEntry)iisDE.Invoke("Create", "IIsWebServer", siteID)) { site.Invoke("Put", "ServerComment", webServerName); site.Invoke("Put", "KeyType", "IIsWebServer"); site.Invoke("Put", "ServerBindings", ":" + port.ToString() + ":"); site.Invoke("Put", "ServerState", 2); site.Invoke("Put", "FrontPageWeb", 1); site.Invoke("Put", "DefaultDoc", "index.aspx"); site.Invoke("Put", "SecureBindings", ":443:"); site.Invoke("Put", "ServerAutoStart", 1); site.Invoke("Put", "ServerSize", 1); site.Invoke("SetInfo"); using (DirectoryEntry siteVDir = site.Children.Add("Root", "IISWebVirtualDir")) { siteVDir.Properties["AppIsolated"][0] = 2; siteVDir.Properties["Path"][0] = path; siteVDir.Properties["AccessFlags"][0] = 513; siteVDir.Properties["FrontPageWeb"][0] = 1; siteVDir.Properties["AppFriendlyName"][0] = webServerName; siteVDir.Invoke("AppCreate", true); siteVDir.CommitChanges(); } site.CommitChanges(); } } private int GetWebSiteInfo(int port) { int result = 1, i = 1; DirectoryEntries des = iisDE.Children; foreach (DirectoryEntry subDE in des) { if (subDE.SchemaClassName == "IIsWebServer") { if ((i = Convert.ToInt32(subDE.Name)) >= result) { result = i + 1; } if (subDE.Properties["ServerBindings"][0].ToString() == ":" + port.ToString() + ":") { throw new Exception(" The port is already used"); } } } des = null; return result; } }} 找到了,<<< 100分,100分 >>> 打包部署。操作iis建立网站(而不是虚拟目录),谢谢了 http://community.csdn.net/Expert/topic/5728/5728241.xml?temp=.6934931里面有孟子的讨论,很好的,JF,JF 对 octverve(生命无色,命运多彩……) 好像没有结果,他们说的,在单独项目里可以建立IIS站点,可是放到安装项目里就不行了,也没办法看到是哪里错了对 Jinglecat(晓风残月 >> 问题需简洁,错误要详细,需求得明确) 在安装项目里添加一个安装类(就是上面的代码),然后在文件系统的"应用程序文件夹"下面添加"项目输出"(这个类的主输出),再在自定义操作里的"安装"添加"自定义操作",添加这个主输出这样没错吧先谢谢两位! 现在可以建了只是建好的站点和直接在IIS上建的不一样(但里面的设置是一样的),浏览站点的时候打开的是http://localhost/localstart.asp而不是http://localhost/Default.aspx直接浏览Default.aspx, 打开后报错:无法找到资源。 说明: HTTP 404。您正在查找的资源(或者它的一个依赖项)可能已被移除,或其名称已更改,或暂时不可用。请检查以下 URL 并确保其拼写正确。请求的 URL: /Default.aspx请问有谁帮助一下??? site.Invoke("Put", "DefaultDoc", "Default.aspx"); 网站打包程序:http://www.cnblogs.com/cncxz/archive/2005/11/30/287602.html 演示应用下载:http://www.cnblogs.com/Files/cncxz/webSetupDemo.rar 开源代码下载::http://www.cnblogs.com/Files/cncxz/webSetupSource.rar 可直接使用! gridview绑定数据问题 textbox的值不能保存 用什么开发工具做这个好 关于页面更新数据的问题 帮大家解决各代码问题,开源个代码给大家 100分,求如何得到复制的内容,在线,结了立即给分。 在web用户控件中制作一个可复用的datagrid时遇到的问题,急! 我快烦死了到底哪个才是IIS,救命啊 关于中英文网站的程序设计及数据库设计问题 asp.net 如何实现网络传真? 为什么treeview的selectednodechanged事件没有触发
不过这些好像都是对虚拟目录的操作,而不是对站点的操作
现在放在"安装项目"的一个类里,却是怎么也不能建立站点有谁做过这一块的,帮助一下using System;
using System.IO;
using System.DirectoryServices;
using System.Reflection;
using System.Data;
using System.Data.SqlClient;
using System.Configuration.Install;
using System.Management;
using System.Collections;
using Microsoft.Win32;
using System.Collections.Specialized;namespace SetupClassLibrary
{
public partial class MyInstaller : Installer
{
static DirectoryEntry iisDE = new DirectoryEntry("IIS://localhost/W3SVC");
public MyInstaller()
{
}
#region Install 安装
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
string serverComment = "MyWebSetup";
string defaultVrootPath = this.Context.Parameters["targetdir"];
if (defaultVrootPath.EndsWith(@"\"))
{
defaultVrootPath = defaultVrootPath.Substring(0, defaultVrootPath.Length - 1);
}
int Port = 9998;
CreateNewIIsWebServer(serverComment, defaultVrootPath, Port);
}
#endregion
public void CreateNewIIsWebServer(string webServerName, string path, int port)
{
int siteID = GetWebSiteInfo(port);
using (DirectoryEntry site = (DirectoryEntry)iisDE.Invoke("Create", "IIsWebServer", siteID))
{
site.Invoke("Put", "ServerComment", webServerName);
site.Invoke("Put", "KeyType", "IIsWebServer");
site.Invoke("Put", "ServerBindings", ":" + port.ToString() + ":");
site.Invoke("Put", "ServerState", 2);
site.Invoke("Put", "FrontPageWeb", 1);
site.Invoke("Put", "DefaultDoc", "index.aspx");
site.Invoke("Put", "SecureBindings", ":443:");
site.Invoke("Put", "ServerAutoStart", 1);
site.Invoke("Put", "ServerSize", 1);
site.Invoke("SetInfo");
using (DirectoryEntry siteVDir = site.Children.Add("Root", "IISWebVirtualDir"))
{
siteVDir.Properties["AppIsolated"][0] = 2;
siteVDir.Properties["Path"][0] = path;
siteVDir.Properties["AccessFlags"][0] = 513;
siteVDir.Properties["FrontPageWeb"][0] = 1;
siteVDir.Properties["AppFriendlyName"][0] = webServerName;
siteVDir.Invoke("AppCreate", true);
siteVDir.CommitChanges();
}
site.CommitChanges();
}
}
private int GetWebSiteInfo(int port)
{
int result = 1, i = 1;
DirectoryEntries des = iisDE.Children;
foreach (DirectoryEntry subDE in des)
{
if (subDE.SchemaClassName == "IIsWebServer")
{
if ((i = Convert.ToInt32(subDE.Name)) >= result)
{
result = i + 1;
}
if (subDE.Properties["ServerBindings"][0].ToString() == ":" + port.ToString() + ":")
{
throw new Exception(" The port is already used");
}
}
}
des = null;
return result;
}
}
}
<<< 100分,100分 >>> 打包部署。操作iis建立网站(而不是虚拟目录),谢谢了 http://community.csdn.net/Expert/topic/5728/5728241.xml?temp=.6934931里面有孟子的讨论,很好的,JF,JF
好像没有结果,他们说的,在单独项目里可以建立IIS站点,可是放到安装项目里就不行了,也没办法看到是哪里错了对 Jinglecat(晓风残月 >> 问题需简洁,错误要详细,需求得明确)
在安装项目里添加一个安装类(就是上面的代码),然后在文件系统的"应用程序文件夹"下面添加"项目输出"(这个类的主输出),再在自定义操作里的"安装"添加"自定义操作",添加这个主输出
这样没错吧先谢谢两位!
http://localhost/localstart.asp而不是http://localhost/Default.aspx
直接浏览Default.aspx, 打开后报错:
无法找到资源。
说明: HTTP 404。您正在查找的资源(或者它的一个依赖项)可能已被移除,或其名称已更改,或暂时不可用。请检查以下 URL 并确保其拼写正确。
请求的 URL: /Default.aspx请问有谁帮助一下???
http://www.cnblogs.com/cncxz/archive/2005/11/30/287602.html
演示应用下载:http://www.cnblogs.com/Files/cncxz/webSetupDemo.rar
开源代码下载::http://www.cnblogs.com/Files/cncxz/webSetupSource.rar
可直接使用!