Tag: iis 6

如何解析.NET中同一父IIS虚拟目录中不同站点的绝对URL?

我的目标是在多个网站上共享图像,css,js等,这些网站都在IIS中的同一父虚拟目录下托管。 当然,我可以对图像路径进行硬编码,但我希望.NET有一种方法可以使用IIS配置智能地解析URL。 这是我的文件/虚拟目录结构: Parent Site (Virtual Directory) default.aspx mypage.aspx otherpage.aspx images – logo.jpg css – site.css Subsite1 (Virtual Directory) – default.aspx – products.aspx Subsite2 (Virtual Directory) – default.aspx – products.aspx – miscellaneous.aspx Parent Site , Subsite1和Subsite2分别是为http: Subsite2和http://subsite2.com设置的虚拟目录。 我想在这些网站上分享图片,js,css等。 .NET中是否有一个方法可以解析~/images/logo.jpg作为http://sofzh.miximages.com/c%23/logo.jpg从其中一个子网点调用(例如, http : //subsite.com/default .aspx )?

如何检测我当前运行的应用程序池? (IIS6)

我需要知道如何检测我正在运行的当前应用程序池,因此我可以通过编程方式对其进行回收。 有谁知道如何为IIS6做这个? 我目前用于回收应用程序池的代码是: /// /// Recycle an application pool /// /// public static void RecycleAppPool(string IIsApplicationPool) { ManagementScope scope = new ManagementScope(@”\\localhost\root\MicrosoftIISv2″); scope.Connect(); ManagementObject appPool = new ManagementObject(scope, new ManagementPath(“IIsApplicationPool.Name=’W3SVC/AppPools/” + IIsApplicationPool + “‘”), null); appPool.InvokeMethod(“Recycle”, null, null); }

System.Web.Routing.RouteCollection.GetRouteData中的exception

我在iis7上运行的asp.net mvc代码中随机获得了两个exception: Exception type: InvalidOperationException Exception message: Collection was modified; enumeration operation may not execute. at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) at System.Collections.Generic.List’1.Enumerator.MoveNextRare() at System.Collections.Generic.List’1.Enumerator.MoveNext() at System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) at System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) at System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 和 Exception type: NullReferenceException Exception message: Object reference not set to an instance of an […]

假冒和授权

我正在使用模拟用于访问UNC共享上的文件,如下所示。 var ctx = ((WindowsIdentity)HttpContext.Current.User.Identity).Impersonate(); string level = WindowsIdentity.GetCurrent().ImpersonationLevel); 在使用IIS6的两台Windows 2003服务器上,我获得了不同的模拟级别:一台服务器上的委派和另一台服务器上的模拟 。 这会导致我无法以“模拟”级别访问服务器上的UNC共享的问题。 什么可能导致这种差异? 我搜索了应用程序池,站点和虚拟目录的machine.config和IIS设置 – 但无法找到此问题的原因。

从ASP.NET执行EXE

我想从ASP.NET MVC应用程序执行一个exe。 是的,我理解这样做的固有风险,但不幸的是我真的需要这样做。 EXE是一个GUI应用程序,但是我传递它的参数强制它以“静默”运行,它在zip文件中生成一些数据然后退出。 执行EXE的代码如下 – 它在我的开发盒上的VS2008中运行正常 – 但是当我对实际服务器(Server 2003 – IIS6)进行测试时,它失败了: ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = “C:\…..”; psi.Arguments = “-silent -file outFile.zip”; Process proc = new Process(); proc.StartInfo = psi; proc.Start(); proc.WaitForExit(); log.Debug(“Process exited: ” + proc.ExitCode); 退出代码是:-532459699,所以显然出了问题。 我通过经过身份validation的HTTPS连接(基本身份validation)在服务器上运行应用程序,所以我想我可以通过在Web.config文件下设置来解决问题。 标记。 但是 – 这没效果。 谢谢 – 所有帮助表示赞赏。

如何使用WMI读取IIS 6网站的目录结构?

我需要在IIS 6.0中使用WMI和C# 读取网站的文件夹 。 我能够使用“IISWebVirtualDirSetting”类读取虚拟目录和应用程序。 但是, 使用此类无法读取位于网站内的物理文件夹。 对于我的情况,我需要阅读位于网站内的子文件夹,然后再设置对它们的设置权限。 根据我的要求,我不需要处理虚拟目录/ Web服务应用程序(可以使用下面的代码轻松获得..)。 我曾尝试使用IISWebDirectory类,但它很有用。 以下是读取IIS虚拟目录的代码… public static ArrayList RetrieveVirtualDirList(String ServerName, String WebsiteName) { ConnectionOptions options = SetUpAuthorization(); ManagementScope scope = new ManagementScope(string.Format(@”\\{0}\root\MicrosoftIISV2″, ServerName), options); scope.Connect(); String SiteId = GetSiteIDFromSiteName(ServerName, WebsiteName); ObjectQuery OQuery = new ObjectQuery(@”SELECT * FROM IISWebVirtualDirSetting”); //ObjectQuery OQuery = new ObjectQuery(@”SELECT * FROM IIsSetting”); ManagementObjectSearcher WebSiteFinder […]

如何使用c#在IIS 6和IIS 7中启用32位应用程序模式

我想使用C#更改Enable32BitAppOnWin64属性。 我知道与IIS 6和IIS 7交互的方式是不同的。 但我需要两个版本的解决方案。

无法打开下载保存对话框

使用下面的代码我无法显示打开/另存为文件对话框: public void ProcessRequest(HttpContext context) { string link = context.Request.QueryString[“Link”]; string extension = Path.GetExtension(link); string fileName = Path.GetFileName(link); string fullPath = String.Format(“{0}\\{1}”, context.Server.MapPath(“~/Content/Uploads/”), fileName); if (File.Exists(fullPath)) { context.Response.ClearContent(); context.Response.ClearHeaders(); context.Response.AddHeader( “Content-Length”, new FileInfo(fullPath).Length.ToString()); string contentType; switch (extension) { default: contentType = “application/octet-stream”; break; } context.Response.ContentType = contentType; context.Response.AddHeader( “Content-Disposition”, String.Format(“attachment; filename={0}”, fileName)); context.Response.WriteFile(fullPath, true); context.Response.Flush(); […]

如何更改我的wsdl的地址位置

我的wsdl在地址位置放了一个错误的域名,如何解决? – – – – – 真正的域名就像https://machine.goodDomain.com.br

IIS6 WebService下Environment.GetFolderPath(Environment.SpecialFolder.ApplicationFolder)返回的错误路径

在运行的测试计算机上(Windows XP,IIS5.1),在自定义进程标识下的C#.NET WebService(.SVC)中执行以下代码(使用machine.config指定用户) Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); 正确回归 c:\Documents and Settings\myUserName\Application Data 但是,在运行IIS6的(终端服务)Windows 2003计算机上执行相同的代码但现在使用ApplicationPool指定相同的进程标识,该方法返回: c:\Documents and Settings\Default User\Application Data 我在Win2003 / IIS6机器上运行时检查过的事情: myUserName属于IIS_WPG组(甚至尝试过管理员) 对Environment.UserName的调用正确返回myUserName 对Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)的调用; 还会返回“默认用户”路径,同样使用DesktopDirectory 以myUserName身份登录并确保C:\ Documents和settings \ myUserName存在 在Windows 2003框中的.net应用程序中运行完全相同的代码,这将工作并返回正确的路径。 我很困惑,它只发生在IIS6下运行时。 它几乎就像是认为呼叫来自网络服务或本地系统用户,而不是检查运行应用程序池的身份。 顺便说一下,当我查看Procmon并观看从Web服务调用的C ++应用程序时,它没有读取和写入C:\ Documents和settings \ myUserName \ ApplicatonData这样的问题,它似乎没有问题,也许它构建了路径不同。 我开始认为这可能是.NET中的一个错误? 谢谢。 汤姆德洛福德