以编程方式加载或排除system.webServer模块

时间:2012-07-30 15:55:11

标签: c# asp.net module

我开发了一个使用第三方DLL的网站。

此DLL声明了一个名为AgeGatewayModule的IHttpModule类。

我无法访问DLL的源代码。

在我的web.config中,我声明了一个configSection&输入配置属性:

<configSections>
<section name="AgeGatewayConfiguration" type="ExternalCompany.AgeGateway.SDK.AgeGatewayConfiguration" />
</configSections>

<AgeGatewayConfiguration
  AgeGatewayUrl="~/Age-Gateway/"
  AccessDeniedUrl="~/Access-Denied/"
  CountryServiceUrl="http://External-Company.svc/v1/" 
LocationServiceUrl="http://External-Company.svc/v1/" 
LdaServiceUrl="http://External-Company.svc/v1/" 
WhiteListingUserAgentsServiceUrl="http://External-Company.svc/v1/UserAgents/" 
WhiteListingReferrersServiceUrl="http://External-Company.svc/v1/Referrers/" 
TokenRealm="http://External-Company.com" 
TokenUserId="xxxx" 
TokenPassword="xxxxxx" 
TokenServiceNamespace="xxxxx" 
TokenAcsHostUrl="accesscontrol.windows.net" 
AllowedGreyCountriesToGlobal="AL" />

最后,模块添加如下:

  <system.webServer>
<modules runAllManagedModulesForAllRequests="true">
  <add name="AgeGatewayModule" type="ExternalCompany.AgeGateway.SDK.AgeGatewayModule, Heineken.AgeGateway.SDK" preCondition="" />
</modules>
<validation validateIntegratedModeConfiguration="false" />

我遇到的问题是:

每次用户第一次访问该网站时 - 该用户都会被重定向到年龄网关页面。

但我希望如果管理员出现并请求某个网址,例如:

 http://my-website/admin/
他们将免于填写年龄网关表格。即重定向不会发生。

web.config中添加的AgeGatewayModule在幕后进行所有检查,并在必要时重定向到age-gateway网址。

所以我希望能说出类似的话:

if(url != "http://my-website/admin/" || CurrentLoggedInUser != admin)
{
//load the AgeGatewayModule only now)
}

这可能吗?

0 个答案:

没有答案
相关问题