澳门新浦京娱乐场网站-www.146.net-新浦京娱乐场官网
做最好的网站

澳门新浦京娱乐场网站操作IIS程序池及站点的创

一、前言

1:没有打SP1补丁的时候会产出这几个IIS6.0假死难题,但今后微软都在自动更新里面出补丁了,平时你打好新型补丁后是不会现身此主题材料了
2:你节制了运用池 的财富过小
3:你限定了内存使用
4:正是服务器本身内部存款和储蓄器太小
5:就是ACCESS数据库太大或询问太多
6:不一样网址用分歧应用池
7:设置回笼时间,很六人感到设置回笼池越短越好,其实是错误的
8:windows 2002类别iis6访谈本机的站点时提示“Service Unavailable”;

眼前在做一个WEB程序的安装包;对某些操作IIS实行三个简约的下结论;首要包蕴对IIS进行站点的新建以及新建站点的NET版本的选项,还大概有指向性IIS7程序池的托管形式以致版本的操作;首先要对Microsoft.Web.Administration举行援引,它根本是用来操作IIS7;

微软生产的EF6框架尽管比较实惠,可是采用的时候会发觉第1回运营加载速度特别慢,何况过风姿浪漫段时间未有加载或访谈又会变慢,以前一贯认为是服务器硬件配置难点或然跟数据库产品有关,后来上网查了材料今后,开掘确实是EF的二个弊病。网络提供了详实的减轻方案,今后摘录下来,便于现在的支出和陈设

颠倒是非提醒如下:

       如今不改其乐,做了叁个配备数据库及IIS网址站点的WPF应用程序工具。

查看iis的行使程序池,景况提醒为:未 内定错误,同一时间接选举拔程序池自动终止运转;
用事件查看器查看系统错误日志,开掘如下提醒:

using System.DirectoryServices;
using Microsoft.Web.Administration;

1.安装Application Initialization

那是在iis8出来后才有的,iis8内置的功力,而对此iis7.5也提供了二个恢宏以援助那些效果。

Application Initialization Module for IIS 7.5

在页面临近底部之处,找到切合本人架构的装置链接

  • x86 for Windows 7
  • x64 for Windows 7 or Windows Server 2008 R2

设置这几个iis模块后,在iis分界面中并从未模块Logo和布署分界面,还须要设置:

设置成功未来会多了一个布置如下图:

复制代码 代码如下:

 

应 用程序-特定 权限设置未将 COM 服务器应用程序(CLSID 为
{A9E69610-B80D-11D0-B9B9-00A0C922E750}
) 的 本地 激活 权限赋予客商 NT AUTHO大切诺基ITYNETWOEnclaveK SERAV4VICE SID (S-1-5-20)。能够动用组件服务处理工科具修正此安全权限。
解决措施,给NETWOQashqaiK SEHighlanderVICE 加上访问iis服务的权位,具体方法如下:
点击“开头”-“调节面板”-“管理工具”-“组件服务”-“Computer”-“小编的Computer”-“DCOM”选项,
接收其下的“IIS ADMIN SE奇骏VICE”,右健选择“属性”,找到“安全”,在“运维和激活权限”中编辑“自定义”,增多帐号“NETWO大切诺基K SE普拉多VICE ”,给该帐号给予“当地运转”和“本地激活”的权柄,重新起动IIS之后再拜见同一站点,则一切符合规律。

1:首先是对本版IIS的版本实行布署:

澳门新浦京娱乐场网站 1

大器晚成经仅配备程序池StartMode为AlwaysRunning还不放心的话,
也足以何况针对站点开启preload和DoAppInitAfterRestart。

安装使用程序池如下图:

澳门新浦京娱乐场网站 2

设置网址如下图

澳门新浦京娱乐场网站 3

配备好后,测量检验了下,效果卓殊对的。
回笼程序池后第三次打开各站点,延迟都十分低。
其实那几个模块的思绪和准时从外表触发一个拜见是同意气风发的,只是,更加好之处在于,它本身在程序池回笼重启的时候就瓜熟蒂落了这事,而不会让外界访谈有机缘会合第三次访谈的气象。

Server Application Unavailable
The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request.

二、内容

9:重启IIS中的特定应 用程序池命令和活动重启的办法
在操作系统是Windows server 二零零一SP1 的处境下,能够用以下命令部分重启IIS应用程序池:
cscript.exe c:windowssystem32iisapp.vbs /a “DefaultAppPool”
其 中/a 代表alternatively,”DefaultAppPool”代表采用程序池的实例名
10:网站有CC攻击

DirectoryEntry getEntity = new DirectoryEntry("IIS://localhost/W3SVC/INFO");
            string Version = getEntity.Properties["MajorIISVersionNumber"].Value.ToString();
            MessageBox.Show("IIS版本为:"   Version);

澳门新浦京娱乐场网站操作IIS程序池及站点的创始布局,Unavailable现身的原由及缓慢解决方案小结。2.用Ngen安装生成EF的地面镜像

由于C#是利用实时 (JIT) 编写翻译器编写翻译原始程序集。由此首先次运维C#前后相继(或Dll)时,程序的起步相当慢。为了升高客户的经验,能够用Microsoft的供的本机影像生成器 (Ngen.exe) 提升程序的属性。Ngen.exe 创设本机影像(包涵经编写翻译的特定于计算机的机械代码的文本),并将它们安装到地面计算机上的本机影象缓存中。运行库可从缓存中使用本机印象,实际不是行使实时 (JIT) 编写翻译器编写翻译原始程序集。

 

1)在指令行中定位到C:WINDOWS澳门新浦京娱乐场网站操作IIS程序池及站点的创始布局,Unavailable现身的原由及缓慢解决方案小结。Microsoft.NETFrameworkv2.0.50727。因为Ngen.exe存放在这地,假如不固定,Ngen.exe不能准明确施行。

cd C:WINDOWSMicrosoft.NETFrameworkv2.0.50727

 

2)生耗费机本机印象。

ngen install D:SystemToolManagerNote.dll   (备注:Dll方式)

 ngen install D:SystemToolManagerNote.exe  (备注:exe方式)

 

3)卸载本机本机影像,请使用与安装时相仿的一声令下行选项。

ngen uninstall D:SystemToolManagerNote.dll

注意:此间依照你协和机器(是32依然64)和.net版本,接收相应的吩咐,只必要安装EntityFramework.SqlServer.dll,因为安信任EntityFramework.dll,会活动安装生成EntityFramework.dll的地头镜像。

现身这种主题素材平日是有以下几个原因:
1、Users组用户对站点文件并未有读写权限 消除办法:给站点目录设置users组读写权限
2、站点Asp.net版本选择不无误这种主题素材会出将来多版本FrameWork共存的情况下,如Asp.net1.1和2.0, 撤销办法:站点-》属性-》选拔当前的Asp.net版本
3、应用程序池冲突消弭办法:在应用程序池-》新建应用程序池,然后在站点-》属性-》主目录 选用刚刚建设构造的运用程序池
留意:以上五个原因想必会同临时候现身,稳步化解就足以了 补充: 有的时候候会现出"ServiceUnavailable",这几个是IIS7中的通用错误,日常原因是:同有时候在线顾客或带宽当先节制、对应的站点地址池停掉(原因超级多)等

       此工具的指标是:

**关于“未钦点的谬误”的难点 的可比正解的消除情势

2:是剖断程序池是存在;

3.EF Pre-Generated Mapping Views(预生成映射视图)

Application_Start出席上面代码:

澳门新浦京娱乐场网站 4

using (var dbcontext = new EFDbContext())
{
    var objectContext = ((IObjectContextAdapter)dbcontext).ObjectContext;
    var mappingCollection = (StorageMappingItemCollection)objectContext.MetadataWorkspace.GetItemCollection(DataSpace.CSSpace);
    mappingCollection.GenerateViews(new List<EdmSchemaError>());
    //对程序中定义的所有DbContext逐一进行这个操作
}

澳门新浦京娱乐场网站 5

Asp.net1.1和2.0标题 独立运用程序池
.net页面文件在浏览的时候出现“Server Application Unavailable”的唤起,日常是出以往.net Framework1.1(或1.0)和.net Framework2.0存世的机械上。

  1. 基于.sql文件在本机上布署数据库
  2. 在本机安插IIS站点,富含新建站点,新建应用程序池。只新建而不会对本机上原本的程序池或站点做校正操作

**找到二种情景:
第大器晚成种缓慢解决措施:使用Ms Access里的“工具->数据库实用工具->压缩和修补数据库”来修补db/global.asa。假设修复后依旧出错,请查看db目录下是还是不是有global.dbl文件,假若有请删除,如不可能删除请结束服务器w3wp.exe进度(win2003)或Aspnet_wp.exe进度(win二零零四)后再删除。

        /// <summary>
        /// 判断程序池是否存在
        /// </summary>
        /// <param name="AppPoolName">程序池名称</param>
        /// <returns>true存在 false不存在</returns>
        private bool IsAppPoolName(string AppPoolName)
        {
            bool result = false;
            DirectoryEntry appPools = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
            foreach (DirectoryEntry getdir in appPools.Children)
            {
                if (getdir.Name.Equals(AppPoolName))
                {
                    result = true;
                }
            }
            return result;
        }

4.补充

倘使您以为这还尚无化解”过了风姿罗曼蒂克段时间不访谈页面然后再一次打开页面变慢“的标题,並且不可能经受第三遍访谈依旧有一点点慢,能够设置使用程序池的”闲时超时“和回笼”固依时期间距“长一些还是建贰个安插职责定期去访问使用了ef的页面,那样给ef热身,让ef不改变冷,那样能够免止长日子不央浼网址,应用程序进度截止再次拜会变慢的难点。设置使用程序池的时光如下图:

澳门新浦京娱乐场网站 6

闲时晚点暗中认可是20分钟,如若在超过20分钟都未有伏乞那一个利用程序池职业历程将在关闭。这里你可以安装依照本身索要设置长一些。

现身该错误的来头正是.net Framework 2.0的顺序和.net Framework1.1(或1.0)的先后被放入同多个应用程序池内,那个时候只要程序页面点击互访,则会并发“Server Application Unavailable(服务器应用程序不可用)”的升迁。

末尾样式:(Check按键的机能是防御与本机已有的站点或程序池有冲突)

第二种解决办法:
设置Internet音信服务(IIS)管理器中的应用程序池,校勘网址的次序池属性,主倘使性质的装置,别的最棒暗中认可设置,

3:删除应用程序池

对此这种处境消灭的秘诀是:在IIS中分头新建三个程序池,二个用来存放.net Framework1.1顺序的目录,三个则用来存放.net Framework2.0主次的目录。

澳门新浦京娱乐场网站 7

调解后就能够缓慢解决难题。
其两种缓和措施:
实质上只要相当粗略的几步:
开始。。。运行。。。regsvr32 jscript.dll开始。。。
运行。。。regsvr32 vbscript.dll开始。。。
运行。。。iisreset

        /// <summary>
        /// 删除指定程序池
        /// </summary>
        /// <param name="AppPoolName">程序池名称</param>
        /// <returns>true删除成功 false删除失败</returns>
        private bool DeleteAppPool(string AppPoolName)
        {
            bool result = false;
            DirectoryEntry appPools = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
            foreach (DirectoryEntry getdir in appPools.Children)
            {
                if (getdir.Name.Equals(AppPoolName))
                {
                    try
                    {
                        getdir.DeleteTree();
                        result = true;
                    }
                    catch
                    {
                        result = false;
                    }
                }
            }
            return result;
        }

而是本人蒙受的情形是那样的:就算机器上还要运转了.net Framework1.1和.net Framework2.0,但因为机器上还未.net Framework1.1的主次文件,所以已经在IIS中早已将.net Framework1.1 web服务扩张举行了不许。同期还新建了特意针对.net Framework2.0的程序池。难题仍然。

 

第七种减轻办法:
HKEY_LOCAL_MACHINESystemCurrentControlSetServicesW3SVCParameters
新建叁个DWOPRADOD项,名为:UseSharedWPDesktop 值为1 重启IIS

4:创立应用程序池 (对程序池的安装重大是本着IIS7;IIS7应用程序池托管格局首要富含合併跟卓绝形式,并拓宽NET版本的设置)

从英特网寻觅找来的气象每一种比对,少之又少有与自己好像的。可是最后依旧找到了部分参照提示,或然是权力难点。文件夹除了超级客户调整权限和IIS进度以外,再也从不别的客户可以访谈,于是尝试增多了一个“User”访谈组,难点随时解决。

 

自家是一直在搜索,也盼望高手教导指导啊!!!

            string AppPoolName = "LamAppPool";
            if (!IsAppPoolName(AppPoolName))
            {
                DirectoryEntry newpool;
                DirectoryEntry appPools = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
                newpool = appPools.Children.Add(AppPoolName, "IIsApplicationPool");
                newpool.CommitChanges();
                MessageBox.Show(AppPoolName   "程序池增加成功");
            }
            #endregion

            #region 修改应用程序的配置(包含托管模式及其NET运行版本)
            ServerManager sm = new ServerManager();
            sm.ApplicationPools[AppPoolName].ManagedRuntimeVersion = "v4.0";
            sm.ApplicationPools[AppPoolName].ManagedPipelineMode = ManagedPipelineMode.Classic; //托管模式Integrated为集成 Classic为经典
            sm.CommitChanges();
            MessageBox.Show(AppPoolName   "程序池托管管道模式:"   sm.ApplicationPools[AppPoolName].ManagedPipelineMode.ToString()   "运行的NET版本为:"   sm.ApplicationPools[AppPoolName].ManagedRuntimeVersion);

自家难题早已减轻,摘录大器晚成篇以留备份。

View:

你只怕感兴趣的稿子:

  • IIS6.0 IIS7.5应用程序池自动截止的解决措施

运用C#代码来对IIS7程序池托管管道格局及版本进行改革;

附一些其余寻觅到的消释办法:

<Window x:Class="AutoWebTool.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:local="clr-namespace:AutoWebTool"
        Title="Web Site Automatic Deployment" Height="500" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.5*"/>
            <RowDefinition Height="0.5*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <GroupBox Header="DataBase Configuration" FontSize="15" BorderThickness="3" Margin="5,10" Grid.Row="0">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="65*"/>
                    <ColumnDefinition Width="133*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Row="0" Grid.Column="0" Text="Server Address" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="15" Height="26" />
                <TextBlock Grid.Row="1" Grid.Column="0" Text="User" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="15" Height="26" />
                <TextBlock Grid.Row="2" Grid.Column="0" Text="Password" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="15" Height="26" />
                <TextBlock Grid.Row="3" Grid.Column="0" Text="Script Path" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="15" Height="26" />

                <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding ServerAddress, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                     HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="15" Width="450" Height="32" />
                <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding User, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                     HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="15" Width="450" Height="32" />
                <PasswordBox Grid.Row="2" Grid.Column="1" PasswordChar="*" local:PasswordBoxHelper.Password="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                     HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="15" Width="450" Height="32">
                    <i:Interaction.Behaviors>
                        <local:PasswordBoxBehavior />
                    </i:Interaction.Behaviors>
                </PasswordBox>
                <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding SqlPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                     HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="15" Width="450" Height="32" />

                <Button Grid.Row="4" Grid.Column="2" Width="70" Height="25" Margin="0,0,10,0"
                        HorizontalAlignment="Left" VerticalAlignment="Center" Content="Browse" Click="FilePathBrowse_Click"/>
            </Grid> 
        </GroupBox>
        <GroupBox Header="WebSite And Pool" FontSize="15" BorderThickness="3" Margin="5,10" Grid.Row="1">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="65*"/>
                    <ColumnDefinition Width="133*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Row="0" Grid.Column="0" Text="WebSite Name" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="15" Height="26" />
                <TextBlock Grid.Row="1" Grid.Column="0" Text="WebSite ID" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="15" Height="26" />
                <TextBlock Grid.Row="2" Grid.Column="0" Text="WebSite PhysicalPath" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="15" Height="26" />
                <TextBlock Grid.Row="3" Grid.Column="0" Text="WebSite Port" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="15" Height="26" />
                <TextBlock Grid.Row="4" Grid.Column="0" Text="Application Pool Name" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="15" Height="26"/>

                <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding WebSiteName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                     HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="15" Width="450" Height="32" />
                <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding WebSiteID, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                     HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="15" Width="450" Height="32" />
                <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding PhysicalPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                     HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="15" Width="450" Height="32" />
                <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding WebSitePort, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                     HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="15" Width="450" Height="32" />
                <TextBox Grid.Row="4" Grid.Column="1" Text="{Binding PoolName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                     HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="15" Width="450" Height="32" />

                <Button Grid.Row="0" Grid.Column="2" Width="70" Height="25" Margin="0,0,10,0"
                        HorizontalAlignment="Left" VerticalAlignment="Center" Content="Check" Click="WebSiteNameCheck_Click"/>
                <Button Grid.Row="1" Grid.Column="2" Width="70" Height="25" Margin="0,0,10,0"
                        HorizontalAlignment="Left" VerticalAlignment="Center" Content="Check" Click="WebSiteIDCheck_Click"/>
                <Button Grid.Row="2" Grid.Column="2" Width="70" Height="25" Margin="0,0,10,0"
                        HorizontalAlignment="Left" VerticalAlignment="Center" Content="Browse" Click="PathBrowse_Click"/>
                <Button Grid.Row="3" Grid.Column="2" Width="70" Height="25" Margin="0,0,10,0"
                        HorizontalAlignment="Left" VerticalAlignment="Center" Content="Check" Click="WebSitePortCheck_Click"/>
                <Button Grid.Row="4" Grid.Column="2" Width="70" Height="25" Margin="0,0,10,0"
                        HorizontalAlignment="Left" VerticalAlignment="Center" Content="Check" Click="PoolNameCheck_Click"/>
            </Grid>
        </GroupBox>
        <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10">
            <Button Width="70" Height="25" Content="OK" Click="Deploy_Click"/>
            <Button Width="70" Height="25" Content="Cancel" Margin="10,0,0,0" Click="Close_Click"/>
        </StackPanel>
    </Grid>
</Window>

澳门新浦京娱乐场网站 8

  1. 在Machine.config中更改客户属性到SYSTEM组。
  2. 加之账户ASPNET的有所央浼的权能:
    1)展开“能源管理器”,退换目录到“Documents and Settings”
    2)假使“LocalService”的目录不可以预知,你须求选拔“工具”-“文件夹选项”,然后您必要确认保障“查看”选项卡中的“隐敝系统文件”未有被入选。
    3)继续到“ Documents and SettingsLocalService”
    4)在“LocalService”文件夹上右击,然后选拔“共享和攀枝花”
    5)在四平选项卡中,增多“ASPNET”客户,确认保障它有“读”、“列表”的权位。
    6)点击“应用”(“明确”),直到全数的窗口关闭。

 

 

**境遇Server Application Unavailable 的管理及消释办法

 

5:针对IIS6的NET版张开安装;因为这里小编是应用NET4.0所以V4.0.30319 假如NET2.0则在此进行退换 v2.0.50727

**前日长久未有测量试验别的的体系先后了,明日相比有食欲,在网络看看三个建站系统,难题是该建站系统是.net写的,要是要看的话,你的种类必得设置了asp.net,近期本身用的体系是豪门都在用的windows xp,并不是windows2002对于不是服务器系统,安装起来以为的确费了点劲,首先本机安装了asp.net2.0,且早先本机已经有iis,那样就先钦点好目录访谈一下呢,但在访谈是出新了一下提醒

View的后台文件:

            //启动aspnet_regiis.exe程序 
            string fileName = Environment.GetEnvironmentVariable("windir")   @"Microsoft.NETFrameworkv4.0.30319aspnet_regiis.exe";
            ProcessStartInfo startInfo = new ProcessStartInfo(fileName);
            //处理目录路径 
            string path = vdEntry.Path.ToUpper();
            int index = path.IndexOf("W3SVC");
            path = path.Remove(0, index);
            //启动ASPnet_iis.exe程序,刷新脚本映射 
            startInfo.Arguments = "-s "   path;
            startInfo.WindowStyle = ProcessWindowStyle.Hidden;
            startInfo.UseShellExecute = false;
            startInfo.CreateNoWindow = true;
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardError = true;
            Process process = new Process();
            process.StartInfo = startInfo;
            process.Start();
            process.WaitForExit();
            string errors = process.StandardError.ReadToEnd();

Server Application Unavailable

using System.Windows;
using System.Windows.Controls;
using System.Windows.Interactivity;

namespace AutoWebTool
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        private AutoGenerationVM _vm;

        public MainWindow()
        {
            InitializeComponent();
            DataContext = new AutoGenerationVM();
            _vm = DataContext as AutoGenerationVM;
        }

        private bool sqlPath;
        private void FilePathBrowse_Click(object sender, RoutedEventArgs e)
        {
            sqlPath = _vm.GetSqlFilePath();
        }



        private void WebSiteNameCheck_Click(object sender, RoutedEventArgs e)
        {
            var isInUse = _vm.CheckNameAndID();
            if (isInUse)
            {
                MessageBox.Show("1.This name is Empty rn2.This name is in use,please change name!");
            }
            else
            {
                MessageBox.Show("No Problem!");
            }
        }

        private void WebSiteIDCheck_Click(object sender, RoutedEventArgs e)
        {
            var isInUse = _vm.CheckNameAndID();
            if (isInUse)
            {
                MessageBox.Show("1.This ID is Empty rn2.This ID is in use,please change ID!");
            }
            else
            {
                MessageBox.Show("No Problem!");
            }
        }

        private bool physicalPath;
        private void PathBrowse_Click(object sender, RoutedEventArgs e)
        {
            physicalPath = _vm.GetFolderPath();
        }
        private void WebSitePortCheck_Click(object sender, RoutedEventArgs e)
        {
            var isInUse = _vm.CheckWebPort();
            if (isInUse)
            {
                MessageBox.Show("1.This port is Empty rn2.This port is in use,please change port!");
            }
            else
            {
                MessageBox.Show("No Problem!");
            }
        }
        private void PoolNameCheck_Click(object sender, RoutedEventArgs e)
        {
            var isInUse = _vm.CkeckPoolName();
            if (isInUse)
            {
                MessageBox.Show("1.This pool name is Empty rn2.This name is in use,please change name!");
            }
            else
            {
                MessageBox.Show("No Problem!");
            }
        }

        private void Deploy_Click(object sender, RoutedEventArgs e)
        {
            var dataBaseServerAddressChecked = string.IsNullOrEmpty(_vm.ServerAddress);
            var dataBaseUserChecked = string.IsNullOrEmpty(_vm.User);
            var dataBasePasswordChecked = string.IsNullOrEmpty(_vm.Password);
            var dataBaseScriptChecked = sqlPath;
            var dataBaseCondition = !dataBaseServerAddressChecked && !dataBaseUserChecked && !dataBasePasswordChecked && !dataBaseScriptChecked;

            var webSiteNameAndIDChecked = _vm.CheckNameAndID();
            var webSitePortChecked = _vm.CheckWebPort();
            var applicationPoolNameChecked = _vm.CkeckPoolName();
            var webSiteCondition = !webSiteNameAndIDChecked && !physicalPath && !webSitePortChecked && !applicationPoolNameChecked;

            if (dataBaseCondition&& webSiteCondition)
            {
                _vm.Execute();
            }
            else {
                MessageBox.Show("Please Check Your Input!");
            }
        }

        private void Close_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }

    public static class PasswordBoxHelper
    {
        public static readonly DependencyProperty PasswordProperty =
            DependencyProperty.RegisterAttached("Password",
            typeof(string), typeof(PasswordBoxHelper),
            new FrameworkPropertyMetadata(string.Empty, OnPasswordPropertyChanged));

        private static void OnPasswordPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var passwordBox = sender as PasswordBox;

            string password = (string)e.NewValue;

            if (passwordBox != null && passwordBox.Password != password)
            {
                passwordBox.Password = password;
            }
        }

        public static string GetPassword(DependencyObject dp)
        {
            return (string)dp.GetValue(PasswordProperty);
        }

        public static void SetPassword(DependencyObject dp, string value)
        {
            dp.SetValue(PasswordProperty, value);
        }
    }

    public class PasswordBoxBehavior : Behavior<PasswordBox>
    {
        protected override void OnAttached()
        {
            base.OnAttached();

            AssociatedObject.PasswordChanged  = OnPasswordChanged;
        }

        private static void OnPasswordChanged(object sender, RoutedEventArgs e)
        {
            var passwordBox = sender as PasswordBox;

            string password = PasswordBoxHelper.GetPassword(passwordBox);

            if (passwordBox != null && passwordBox.Password != password)
            {
                PasswordBoxHelper.SetPassword(passwordBox, passwordBox.Password);
            }
        }

        protected override void OnDetaching()
        {
            base.OnDetaching();

            AssociatedObject.PasswordChanged -= OnPasswordChanged;
        }
    }
}

6:平时大家可能还得对IIS中的MIME类型进行充实;下边首假设我们用到七个门类分别是:xaml,xap

The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request.

 

            IISOle.MimeMapClass NewMime = new IISOle.MimeMapClass();
            NewMime.Extension = ".xaml"; NewMime.MimeType = "application/xaml xml";
            IISOle.MimeMapClass TwoMime = new IISOle.MimeMapClass();
            TwoMime.Extension = ".xap"; TwoMime.MimeType = "application/x-silverlight-app";
            rootEntry.Properties["MimeMap"].Add(NewMime);
            rootEntry.Properties["MimeMap"].Add(TwoMime);
            rootEntry.CommitChanges();

Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.

ViewModel:

 

其一难点好疑似在以前测量试验的时候遇到过,那是周围还是用的是asp.net1.0的呢。反正是忘记了,从互连网找了相当多相关的拍卖方法始终是尚未缓和,找到特别盲目标时候,测验那些情势就打响了!

using System;
using System.DirectoryServices;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using Microsoft.Web.Administration;
using System.Windows.Forms;
using System.Diagnostics;
using System.Data.SqlClient;
using System.IO;

namespace AutoWebTool
{
    public class AutoGenerationVM : INotifyPropertyChanged
    {

        public AutoGenerationVM()
        {
            _physicalPath = AppDomain.CurrentDomain.BaseDirectory;
        }

        //DataBase ServerAddress
        private string _serverAddress = string.Empty;

        public string ServerAddress
        {
            get { return _serverAddress; }
            set
            {
                if (_serverAddress != value)
                {
                    _serverAddress = value;
                    NotifyPropertyChanged("ServerAddress");
                }
            }
        }


        //DataBase User
        private string _user = string.Empty;

        public string User
        {
            get { return _user; }
            set
            {
                if (_user != value)
                {
                    _user = value;
                    NotifyPropertyChanged("User");
                }
            }
        }


        //DataBase Password
        private string _password = string.Empty;

        public string Password
        {
            get { return _password; }
            set
            {
                if (_password != value)
                {
                    _password = value;
                    NotifyPropertyChanged("Password");
                }
            }
        }


        //DataBase SQLPath
        private string _sqlPath = string.Empty;

        public string SqlPath
        {
            get { return _sqlPath; }
            set
            {
                if (_sqlPath != value)
                {
                    _sqlPath = value;
                    NotifyPropertyChanged("SqlPath");
                }
            }
        }


        public bool GetSqlFilePath() {

            var openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "数据库脚本文件|*.sql";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                SqlPath = openFileDialog.FileName;
            }
            return false;
        }


        //                                                               
        //WebSite Name
        private string _webSiteName = string.Empty;

        public string WebSiteName
        {
            get { return _webSiteName; }
            set
            {
                if (_webSiteName != value)
                {
                    _webSiteName = value;
                    NotifyPropertyChanged("WebSiteName");
                }
            }
        }



        //WebSite ID
        private string _webSiteID = string.Empty;

        public string WebSiteID
        {
            get { return _webSiteID; }
            set
            {
                if (_webSiteID != value)
                {
                    _webSiteID = value;
                    NotifyPropertyChanged("WebSiteID");
                }
            }
        }


        /// <summary>
        /// Check WebSite Name and ID
        /// </summary>
        /// <returns></returns>
        public bool CheckNameAndID()
        {
            if (string.IsNullOrEmpty(WebSiteName) || string.IsNullOrEmpty(WebSiteID)) return true;

            DirectoryEntry rootEntry = new DirectoryEntry("IIS://localhost/w3svc");
            foreach (DirectoryEntry entry in rootEntry.Children)
            {
                if (entry.SchemaClassName.Equals("IIsWebServer", StringComparison.OrdinalIgnoreCase))
                {
                    if (WebSiteID == entry.Name) {
                        return true;
                    }
                    if (entry.Properties["ServerComment"].Value.ToString() == WebSiteName)
                    {
                        return true;
                    }
                }
            }
            return false;
        }


        //Physical Path
        private string _physicalPath = string.Empty;

        public string PhysicalPath
        {
            get { return _physicalPath; }
            set
            {
                if (_physicalPath != value)
                {
                    _physicalPath = value;
                    NotifyPropertyChanged("PhysicalPath");
                }
            }
        }

        /// <summary>
        /// Get Path for WebSite
        /// </summary>
        public bool GetFolderPath()
        {
            if (string.IsNullOrEmpty(PhysicalPath)) return true;
            var openFolderDialog = new FolderBrowserDialog();
            if (openFolderDialog.ShowDialog() == DialogResult.OK)
            {
                PhysicalPath = openFolderDialog.SelectedPath;
            }
            return false;
        }

        //WebSite Port
        private string _webSitePort = string.Empty;

        public string WebSitePort
        {
            get { return _webSitePort; }
            set
            {
                if (_webSitePort != value)
                {
                    _webSitePort = value;
                    NotifyPropertyChanged("WebSitePort");
                }
            }
        }


        /// <summary>
        /// Check WebSite Port
        /// </summary>
        /// <returns></returns>
        public bool CheckWebPort()
        {
            try
            {
                IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
                IPEndPoint[] ipEndPoints = ipProperties.GetActiveTcpListeners();

                foreach (IPEndPoint endPoint in ipEndPoints)
                {
                    if (endPoint.Port == Convert.ToInt32(WebSitePort))
                    {
                        return true;
                    }
                }
                return false;

            }
            catch {

                return true;
            }           
        }


        //Pool Name
        private string _poolName = string.Empty;

        public string PoolName
        {
            get { return _poolName; }
            set
            {
                if (_poolName != value)
                {
                    _poolName = value;
                    NotifyPropertyChanged("PoolName");
                }
            }
        }


        /// <summary>
        /// Check Application Pool Name
        /// </summary>
        /// <returns></returns>
        public bool CkeckPoolName()
        {
            if (string.IsNullOrEmpty(PoolName)) return true;
            var manager = new ServerManager();
            var list = manager.ApplicationPools;
            var matchedItem =  list.FirstOrDefault(x => x.Name == PoolName);
            if (matchedItem != null)
                return true;
            return false;
        }


        /// <summary>
        /// Execute Script
        /// </summary>
        public void Execute()
        {
            //Deploy DataBase
            var tmpConn = new SqlConnection();
            tmpConn.ConnectionString = "SERVER = "   ServerAddress  "; DATABASE = master; User ID = "   User  "; Pwd = "   Password  ";";
            var scriptFile = new FileInfo(SqlPath);
            var sqlCreateDBQuery = scriptFile.OpenText().ReadToEnd();
            SqlCommand myCommand = new SqlCommand(sqlCreateDBQuery, tmpConn);
            try
            {
                tmpConn.Open();
                myCommand.ExecuteNonQuery();
                MessageBox.Show("Database has been created successfully!","Create Database", MessageBoxButtons.OK,MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Create Database", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                tmpConn.Close();

            }



            try
            {
                //Deploy WebSite and Application Pool
                var script = "net start w3svc "  
                             "& cd c:/Windows/System32/inetsrv "  
                             "& appcmd add site /name:"   WebSiteName   " /id:"   WebSiteID  
                             " /physicalPath:"   PhysicalPath   " /bindings:http/*:"   WebSitePort   ":"   WebSiteName  
                             " & appcmd add apppool /name:"   PoolName   " /managedRuntimeVersion:v4.0 /managedPipelineMode:Integrated"  
                             " & appcmd set site /site.name:"   WebSiteName   " /[path='/'].applicationPool:"   PoolName;

                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.WorkingDirectory = @"C:WindowsSystem32";
                startInfo.FileName = @"C:WindowsSystem32cmd.exe";
                startInfo.RedirectStandardInput = true;
                startInfo.RedirectStandardOutput = true;
                startInfo.RedirectStandardError = true;
                startInfo.UseShellExecute = false;
                startInfo.Verb = "RunAs";

                Process process = new Process();
                process.StartInfo = startInfo;
                process.Start();
                process.StandardInput.WriteLine(script);
                process.StandardInput.WriteLine("&exit");
                process.StandardInput.Flush();
                process.StandardInput.Close();
                process.WaitForExit();

                MessageBox.Show("IIS WebSite and Application Pool Deployed Successfully!", "Create WebSite and Application Pool", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(string name)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }
    }
}

7:上边是做安装时生机勃勃段对IIS举办操作的代码;宽容IIS6及IIS7;新建设想目录并对相应的性质进行设置;对IIS7还张开新建程序池的次序;并设置程序池的布署;

Server Application Unavailable杀绝办法windows xp 版 揭幕啦!

 

 

在 IIS 中注册 ASP.NET

/// <summary>
    /// 创建网站
    /// </summary>
    /// <param name="siteInfo"></param>
      public  void CreateNewWebSite(NewWebSiteInfo siteInfo)
        {
            if (!EnsureNewSiteEnavaible(siteInfo.BindString))
            {
                throw new Exception("该网站已存在"   Environment.NewLine   siteInfo.BindString);
            }
            DirectoryEntry rootEntry = GetDirectoryEntry(entPath);

            newSiteNum = GetNewWebSiteID();
            DirectoryEntry newSiteEntry = rootEntry.Children.Add(newSiteNum, "IIsWebServer");
            newSiteEntry.CommitChanges();

            newSiteEntry.Properties["ServerBindings"].Value = siteInfo.BindString;
            newSiteEntry.Properties["ServerComment"].Value = siteInfo.CommentOfWebSite;
            newSiteEntry.CommitChanges();
            DirectoryEntry vdEntry = newSiteEntry.Children.Add("root", "IIsWebVirtualDir");
            vdEntry.CommitChanges();
            string ChangWebPath = siteInfo.WebPath.Trim().Remove(siteInfo.WebPath.Trim().LastIndexOf('\'),1);
            vdEntry.Properties["Path"].Value = ChangWebPath;


            vdEntry.Invoke("AppCreate", true);//创建应用程序

            vdEntry.Properties["AccessRead"][0] = true; //设置读取权限
            vdEntry.Properties["AccessWrite"][0] = true;
            vdEntry.Properties["AccessScript"][0] = true;//执行权限
            vdEntry.Properties["AccessExecute"][0] = false;
            vdEntry.Properties["DefaultDoc"][0] = "Login.aspx";//设置默认文档
            vdEntry.Properties["AppFriendlyName"][0] = "LabManager"; //应用程序名称           
            vdEntry.Properties["AuthFlags"][0] = 1;//0表示不允许匿名访问,1表示就可以3为基本身份验证,7为windows继承身份验证
            vdEntry.CommitChanges();

            //操作增加MIME
            //IISOle.MimeMapClass NewMime = new IISOle.MimeMapClass();
            //NewMime.Extension = ".xaml"; NewMime.MimeType = "application/xaml xml";
            //IISOle.MimeMapClass TwoMime = new IISOle.MimeMapClass();
            //TwoMime.Extension = ".xap"; TwoMime.MimeType = "application/x-silverlight-app";
            //rootEntry.Properties["MimeMap"].Add(NewMime);
            //rootEntry.Properties["MimeMap"].Add(TwoMime);
            //rootEntry.CommitChanges();

            #region 针对IIS7
            DirectoryEntry getEntity = new DirectoryEntry("IIS://localhost/W3SVC/INFO");
            int Version =int.Parse(getEntity.Properties["MajorIISVersionNumber"].Value.ToString());
            if (Version > 6)
            {
                #region 创建应用程序池
                string AppPoolName = "LabManager";
                if (!IsAppPoolName(AppPoolName))
                {
                    DirectoryEntry newpool;
                    DirectoryEntry appPools = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
                    newpool = appPools.Children.Add(AppPoolName, "IIsApplicationPool");
                    newpool.CommitChanges();
                }
                #endregion

                #region 修改应用程序的配置(包含托管模式及其NET运行版本)
                ServerManager sm = new ServerManager();
                sm.ApplicationPools[AppPoolName].ManagedRuntimeVersion = "v4.0";
                sm.ApplicationPools[AppPoolName].ManagedPipelineMode = ManagedPipelineMode.Classic; //托管模式Integrated为集成 Classic为经典
                sm.CommitChanges();
                #endregion

                vdEntry.Properties["AppPoolId"].Value = AppPoolName;
                vdEntry.CommitChanges();
            }
            #endregion


            //启动aspnet_regiis.exe程序 
            string fileName = Environment.GetEnvironmentVariable("windir")   @"Microsoft.NETFrameworkv4.0.30319aspnet_regiis.exe";
            ProcessStartInfo startInfo = new ProcessStartInfo(fileName);
            //处理目录路径 
            string path = vdEntry.Path.ToUpper();
            int index = path.IndexOf("W3SVC");
            path = path.Remove(0, index);
            //启动ASPnet_iis.exe程序,刷新脚本映射 
            startInfo.Arguments = "-s "   path;
            startInfo.WindowStyle = ProcessWindowStyle.Hidden;
            startInfo.UseShellExecute = false;
            startInfo.CreateNoWindow = true;
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardError = true;
            Process process = new Process();
            process.StartInfo = startInfo;
            process.Start();
            process.WaitForExit();
            string errors = process.StandardError.ReadToEnd();
            if (errors != string.Empty)
            {
                throw new Exception(errors);
            }

        }

string entPath = String.Format("IIS://{0}/w3svc", "localhost");

public  DirectoryEntry GetDirectoryEntry(string entPath)
       {
           DirectoryEntry ent = new DirectoryEntry(entPath);
           return ent;
       }

        public class NewWebSiteInfo
        {
            private string hostIP;   // 主机IP
            private string portNum;   // 网站端口号
            private string descOfWebSite; // 网站表示。一般为网站的网站名。例如"www.dns.com.cn"
            private string commentOfWebSite;// 网站注释。一般也为网站的网站名。
            private string webPath;   // 网站的主目录。例如"e: mp"

            public NewWebSiteInfo(string hostIP, string portNum, string descOfWebSite, string commentOfWebSite, string webPath)
            {
                this.hostIP = hostIP;
                this.portNum = portNum;
                this.descOfWebSite = descOfWebSite;
                this.commentOfWebSite = commentOfWebSite;
                this.webPath = webPath;
            }

            public string BindString
            {
                get
                {
                    return String.Format("{0}:{1}:{2}", hostIP, portNum, descOfWebSite); //网站标识(IP,端口,主机头值)
                }
            }

            public string PortNum
            {
                get
                {
                    return portNum;
                }
            }

            public string CommentOfWebSite
            {
                get
                {
                    return commentOfWebSite;
                }
            }

            public string WebPath
            {
                get
                {
                    return webPath;
                }
            }
        }

开垦作者的计算机,踏向系统所在的盘(若是为 C 盘),踏入以下门路C:WINDOWSMicrosoft.NETFramework,在这里边,您拜会到您安装的比不上版本的 .NET 框架目录,假诺您的网站使用的 .NET 版本为 2.0,则踏向 v2.0.50727 目录 (完整路线为:C:WINDOWSMicrosoft.NETFrameworkv2.0.50727)。

8:上面的代码是对文本夹权限举行设置,下边代码是创设伊芙ryone 并授予全体权力

在该目录下,能看见二个命名称叫 aspnet_regiis.exe 的文本,那是一个命令符推行文书。

        /// <summary>
        /// 设置文件夹权限 处理给EVERONE赋予所有权限
        /// </summary>
        /// <param name="FileAdd">文件夹路径</param>
        public void SetFileRole()
        {
            string FileAdd = this.Context.Parameters["installdir"].ToString();
            FileAdd = FileAdd.Remove(FileAdd.LastIndexOf('\'), 1);
            DirectorySecurity fSec = new DirectorySecurity();
            fSec.AddAccessRule(new FileSystemAccessRule("Everyone",FileSystemRights.FullControl,InheritanceFlags.ContainerInherit|InheritanceFlags.ObjectInherit,PropagationFlags.None,AccessControlType.Allow));
            System.IO.Directory.SetAccessControl(FileAdd, fSec);
        }

点 “发轫 / 运维”,在“张开” 这里输入 “cmd”,回车,那样就能够张开命令符运转窗口,将最近路径改正到 C:WINDOWSMicrosoft.NETFrameworkv2.0.50727,输入 aspnet_regiis.exe -i 回车就能够。

 

因此以上操作,开端从地方栏中测量试验访谈安装目录文件,开掘真正能够访谈到了,难点消除了!希望以上操作对看见此篇作品你的您也推动扶持,借使不可能化解你的主题材料,再多找找别的的解决办法!

 

你也许感兴趣的篇章:

  • 网址出现503(503 瑟维斯 Temporarily UnavailableThe requested)服务一时半刻不可用的消除方法小结
  • 卸载ZkeysPHP 后iis网址现身Service Unavailable 化解办法
  • iis ServiceUnavailable解决措施(权限难题)
  • win2003 iis6.0 NET2.0的Server Application Unavailable的问题!
  • Service Unavailable 原因深入分析
  • ServiceUnavailable产生的由来
  • 公布WEB站点时现身Server Application Unavailable
  • Service Temporarily Unavailable的503不当是怎么回事?

 

前段时间有个小妹弄的一个关于扩张眼界跟内含的订阅号,每一日都会更新一些纵深内容,在这里处假设你感兴趣也能够关心一下(嘿对雅观的女孩子跟文化感兴趣),当然能够关心后输入:github 会有小编的微信号,假若至极你也能够在这里找到本人;当然不感兴趣无视此新闻;

澳门新浦京娱乐场网站 9

本文由澳门新浦京娱乐场网站发布于www.146.net,转载请注明出处:澳门新浦京娱乐场网站操作IIS程序池及站点的创