IIS7 Microsoft.Web.Administration 创建Application问题

在使用DirectoryEntry操作IIS时,可以设置很多属性。但使用Microsoft.Web.Administration中的一些类时,不知道在哪设置。例如:AccessScript,AccessRead,目录浏览,匿名访问等属性。我现在写的代码如下:

复制代码
 using(ServerManager sm = new ServerManager())
{
ApplicationPool newPool = sm.ApplicationPools["NewPool"];
if (newPool == null)
{
newPool = sm.ApplicationPools.Add("NewPool");
newPool.AutoStart = true;
newPool.ManagedRuntimeVersion = "v4.0";
newPool.Enable32BitAppOnWin64 = true;
sm.CommitChanges();
}
Site defaultSite = sm.Sites["Default Web Site"];
Application newApplication = defaultSite.Applications["NewApplication"];
if(newApplication!=null)
{
defaultSite.Applications.Remove(newApplication);
}
newApplication = defaultSite.Applications.Add("/NewApplication",
@"F:\Silverlight\PrismModule\PrismModule.Web");

newApplication.ApplicationPoolName = "NewPool";
sm.CommitChanges();
}
复制代码

这样也能正确在Default Web Site下创建一个应用程序,我想知道上面提到的那些属性如何设置?

 

  问题解决。IIS7中关于站点的配置信息时通过config文件存储的,主要在applicaitonhost.config和web.config中设置。用到Microsoft.Web.Administration中的Configuration类

 

转载于:https://www.cnblogs.com/lizhenlin/p/7214512.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 Unity WebGL 中,使用 `Microsoft.Web.Administration` 库会出现编译错误,因为该库是基于 Windows Server 上的 IIS 管理器开发的,而不是基于浏览器的 WebGL 环境。 如果需要在 Unity WebGL 中进行 Web 开发,可以使用 JavaScript 或 TypeScript 语言编写代码,并结合 HTML、CSS 等前端技术来实现。可以使用 Unity 提供的 `Application.ExternalEval` 方法来在 JavaScript 和 C# 之间进行通信。 以下是在 Unity WebGL 中使用 JavaScript 实现启动本地 HTTP 服务器的示例代码: ```javascript function startHttpServer() { var http = require('http'); var fs = require('fs'); var path = require('path'); var server = http.createServer(function (req, res) { var filePath = '.' + req.url; if (filePath == './') { filePath = './index.html'; } var extname = path.extname(filePath); var contentType = 'text/html'; switch (extname) { case '.js': contentType = 'text/javascript'; break; case '.css': contentType = 'text/css'; break; case '.json': contentType = 'application/json'; break; case '.png': contentType = 'image/png'; break; case '.jpg': contentType = 'image/jpg'; break; case '.wav': contentType = 'audio/wav'; break; } fs.readFile(filePath, function(error, content) { if (error) { if(error.code == 'ENOENT'){ res.writeHead(404); res.end('404 Not Found'); res.end(); } else { res.writeHead(500); res.end('500 Internal Server Error'); res.end(); } } else { res.writeHead(200, { 'Content-Type': contentType }); res.end(content, 'utf-8'); } }); }); server.listen(8000); } ``` 在上述 JavaScript 代码中,使用 Node.js 的 `http` 模块来创建一个本地 HTTP 服务器,监听端口为 8000。在浏览器中访问 `http://localhost:8000`,即可看到当前目录下的文件列表,点击相应文件即可下载。 在 Unity C# 代码中,使用 `Application.ExternalEval` 方法来调用 JavaScript 代码,示例代码如下: ```csharp using UnityEngine; public class HttpServer : MonoBehaviour { void Start() { Application.ExternalEval("startHttpServer();"); } } ``` 在 `Start` 方法中,使用 `Application.ExternalEval` 方法调用 JavaScript 代码中的 `startHttpServer` 函数,启动本地 HTTP 服务器。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值