QA团队发现,当网络服务器(提供嵌入式设备用户界面)在主DNS服务器无法访问的系统上运行时,用户界面变得难以忍受 - 每次操作需要16个。
首先,我认为提供静态页面并没有遇到这个问题。
不包括我的第一个嫌疑人 - 记录 - 我终于找到了原因给Intelligencia.UrlRewriter(nuget package ver.2.0.0.9)。看来,在每个请求中,重写器都会复制所有服务器变量,其中包括“REMOTE_HOST”。这是一个动态变量,仅在需要时运行。这又涉及到HttpRequest.UserHostName的调用。
问题很简单:如何在使用UrlRewriter的Web应用程序中避免反向地址查找?
我自己提供一把大锤回答,但我想听听其他选择。
答案 0 :(得分:0)
我添加了另一个带有简单http模块的类库项目:
public sealed class NoRemoteHostLookup : IHttpModule
{
public void Dispose()
{
}
public void Init(HttpApplication context)
{
context.BeginRequest += ContextOnBeginRequest;
}
private void ContextOnBeginRequest(object sender, EventArgs eventArgs)
{
var request = HttpContext.Current?.Request;
if (request != null)
request.ServerVariables["REMOTE_HOST"] = request.ServerVariables["REMOTE_ADDR"];
}
}
然后由Web应用程序项目引用,并在 UrlRewriter之前在web.config 中配置:
<system.web>
<httpModules>
<add type="NoRemoteHostLookupModule.NoRemoteHostLookup, NoRemoteHostLookupModule" name="NoRemoteHostLookup" />
<add type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" name="UrlRewriter" />
</httpModules>
</system.web>