如果在同一个应用程序池中运行多个ASP.NET应用程序,那么我将拥有一个类的静态变量实例数量?
只是给出一些背景:
我正在考虑一个ServiceLocator实现,它在一个静态类变量中包含一个UnityContainer.问题是,在ServiceLocator上注册容器的多个应用程序会相互干扰吗?
这些应用程序在.NET 4.0上的IIS 7.5中运行,应该有所不同.
示例代码(简化)
public static class ServiceLocator
{
private static IUnityContainer _container;
public static void Initialize(IUnityContainer container)
{
if (_container != null)
{
throw new ApplicationException("Initialize should only be called once!");
}
_container = container;
}
}
Run Code Online (Sandbox Code Playgroud)
如果我从在同一个应用程序池中运行的两个不同的Web应用程序运行它,通常在Application_Start中,它会在第二次调用时抛出异常吗?它总会引发异常吗?它永远不会抛出异常吗?它会在某些配置中引发异常吗?
更新:我知道每个应用程序域将有一个静态变量实例.因此,问题可以改为"如果在同一个应用程序池中运行多个ASP.NET应用程序,我将拥有多少个应用程序域?"
我一直在寻找很多,但没有找到任何权威的参考.任何帮助表示赞赏,最好参考官方Microsoft文档.
我对TeamCity有一个相当奇怪的问题.我有一个TeamCity安装,带有本地和远程构建代理.TeamCity服务器隐藏在IIS后面,带有应用程序请求路由(ARR),以启用SSL等.我感觉这可能是问题的一部分,但我不确定.怀疑IIS是问题的一部分的另一个原因是,我试图在Azure Web App上托管TeamCity,并且得到了完全相同的行为.
问题是,在构建之后,当构建代理尝试将工件发布到服务器时,我从TeamCity服务器返回404.TeamCity认为这是一个可恢复的错误(请参阅日志),并且有时会再次尝试.最终,发布失败了.
如果我将本地代理配置为通过访问TeamCity http://localhost
,一切顺利.但是,当通过公共地址(通过IIS提供)访问时,我得到404s.404内容看起来像标准的IIS 404页面.
我尝试将代理记录详细程度设置为DEBUG
,但它仍然不输出它尝试调用的实际URL.
有没有人有任何关于如何解决这个问题的线索?让TeamCity代理输出它获得404的URL将是一个良好的开端.
[Publishing artifacts] Publishing 1 file [F:/tc/ba3/temp/buildTmp/out/_PublishedWebSites/**/* => dist.zip] using [WebPublisher]
[15:34:15][Publishing artifacts] Publishing 1 file [F:/tc/ba3/temp/buildTmp/out/_PublishedWebSites/**/* => dist.zip] using [ArtifactsCachePublisher]
[15:35:10]
[Publishing artifacts] Recoverable problem publishing artifacts (will retry): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">;
<html xmlns="http://www.w3.org/1999/xhtml">;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>404 - File or directory not found.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用PowerShell脚本将用户IIS AppPool\ASP.NET v4.0添加到性能监视器用户组,以便能够使用ASP.NET应用程序中的自定义性能计数器.但是,我无法弄清楚如何使用ADSI解决自动创建的ASP.NET用户.
这对我有用:
$computer = $env:COMPUTERNAME;
$user = [ADSI]"WinNT://$computer/Administrator,user"
$groupToAddTo = "TestGroup"
$parent = [ADSI]"WinNT://$computer/$groupToAddTo,group"
$parent.Add($user.Path)
Run Code Online (Sandbox Code Playgroud)
但是,我无法弄清楚如何找到ASP.NET v4.0用户:
$computer = $env:COMPUTERNAME;
# $user = [ADSI]"WinNT://$computer/IIS AppPool/ASP.NET v4.0,user" # <-- Doesn't work
$groupToAddTo = "TestGroup"
$parent = [ADSI]"WinNT://$computer/$groupToAddTo,group"
$parent.Add($user.Path)
Run Code Online (Sandbox Code Playgroud)
有关如何使用ADSI解决该用户的任何线索?或者,使用Powershell或其他命令行工具实现我想要的任何其他出色方法?GUI工作正常,但自动化是关键.
我不是Razor语法的大师,而是尝试使用流畅的àlàTelerik的GUI组件来构建通用库.
我有以下几件(大约):
public static MyBox Box(this HtmlHelper helper)
{
return new MyBox(helper.ViewContext);
}
Run Code Online (Sandbox Code Playgroud)
和:
/// <summary>
/// http://geekswithblogs.net/shaunxu/archive/2010/04/10/lt-gt-htmlencode-ihtmlstring-and-mvchtmlstring.aspx
/// </summary>
public class MyBox : IHtmlString
{
private readonly ViewContext _viewContext;
private string _content;
private string _title;
public MyBox(ViewContext viewViewContext)
{
_viewContext = viewViewContext;
}
/// <summary>
/// See: http://haacked.com/archive/2011/02/27/templated-razor-delegates.aspx
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public MyBox Content(Func<object, object> value)
{
_content = value.DynamicInvoke(_viewContext).ToString();
return this;
}
/// <summary>
/// See: http://haacked.com/archive/2011/02/27/templated-razor-delegates.aspx
/// </summary>
/// <param name="values"></param>
/// <returns></returns> …
Run Code Online (Sandbox Code Playgroud) 在Visual Studio中打开视图编译时遇到问题.我有一个相当标准的ASP.NET MVC 5应用程序,有很多参考.我引用System.Web.Mvc 5.2.3.0(最新版本),但编译似乎与v.5.2.2.0 vs 5.2.3.0有问题.优秀的工具AsmSpy(https://github.com/mikehadlow/AsmSpy)告诉我哪些程序集引用了System.Web.Mvc的哪个版本:
Reference: System.Web.Mvc
5.1.0.0 by Autofac.Integration.Mvc
5.0.0.0 by Glimpse.Mvc5
5.0.0.0 by Microsoft.Web.Mvc
3.0.0.0 by Mindscape.Raygun4Net.Mvc
5.2.3.0 by Myrepo.Web.Common
5.2.3.0 by MyApp
5.2.2.0 by Thinktecture.IdentityModel.Owin.ResourceAuthorization.Mvc
Run Code Online (Sandbox Code Playgroud)
所以,有罪的是Thinktecture.IdentityModel.Owin.ResourceAuthorization.Mvc.但是,我已经将程序集绑定重定向添加到应用程序的根web.config,如下所示:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- lots more -->
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<!-- lots more -->
</assemblyBinding>
</runtime>
Run Code Online (Sandbox Code Playgroud)
为了试图找到问题的根源,我打开了Diagnostic构建日志,它在260,000行日志中向外吐出,包括:
16> Unified primary reference "System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". (TaskId:183)
16> Using this version instead of original version "5.1.0.0" in "C:\Users\ErikBrandstadmoen\Source\Repos\myrepo\packages\Autofac.Mvc5.3.3.4\lib\net45\Autofac.Integration.Mvc.dll" because of a …
Run Code Online (Sandbox Code Playgroud) 我在严重HttpClient
负载下遇到严重问题.我创建了一个GitHub repo来演示这个问题.非常感谢任何帮助.是的,我HttpClient
每个权限只使用一个.http和https也有同样的问题.这不是服务器端问题,因为服务器始终保持响应.
https://github.com/erikbra/HttpClientProblems/issues/1
通常会收到以下错误.System.Net
跟踪日志说它正在调用::Abort
连接.但很难获得更多信息.
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.WinHttpException: The connection with the server was terminated abnormally
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.Tasks.RendezvousAwaitable`1.GetResult()
at System.Net.Http.WinHttpHandler.<StartRequest>d__105.MoveNext()
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at System.Net.Http.HttpClient.<FinishSendAsyncBuffered>d__58.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at UnitTests.Call_Api.<CallApi>d__22.MoveNext() in C:\Users\ErikBrandstadmoen\Source\Repos\HttpClientProblems\UnitTests.NetCore\Call_Api.cs:line 204
--- End …
Run Code Online (Sandbox Code Playgroud) .net ×2
c# ×2
.net-core ×1
adsi ×1
arr ×1
asp.net ×1
asp.net-mvc ×1
css ×1
iis ×1
javascript ×1
jquery ×1
powershell ×1
razor ×1
teamcity ×1
windows ×1