2016-04-20 6 views
3

IIS6からIIS8に移行する過程で、私たちのWebサイトを新しいWebサーバーに移行しました。 1つのことを除いて、すべてが期待どおりに機能します。ユーザーがセッションフォーム認証の期限が切れた後にページを読み込むと、null参照例外が発生します。ASP.netページは、フォーム認証リダイレクトの後に読み込みを続行します

ユーザ自身がログインページに正しくリダイレ​​クトされますが、読み込まれた元のページは引き続き実行され、ログインするユーザに依存するページの一部に達すると、 null参照例外が発生しました。

IIS6では、この問題は一度も起こりませんでした。IIS8では、これを数百回取得していますが、これはかなり面倒です。

これは単なる設定の問題かもしれないが、これまでのところ、私のグーグルでは、あなたのアプリケーションプールを設定してみてください(有罪を保護するために、わずかに編集さ)何

のWeb.config

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> 
    <configSections> 
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
     <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
     <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> 
     <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
      <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" /> 
      <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> 
      <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> 
      <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> 
     </sectionGroup> 
     </sectionGroup> 
    </sectionGroup> 
    <section name="log4net" type="System.Configuration.IgnoreSectionHandler" /> 
    </configSections> 
    <system.web> 
    <pages enableViewStateMac="true"> 
     <controls> 
     <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     </controls> 
    </pages> 
    <httpRuntime maxRequestLength="8192" executionTimeout="800" /> 
    <httpHandlers> 
     <remove path="*.asmx" verb="*" /> 
     <add path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" /> 
     <add path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" /> 
     <add path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" /> 
     <add path="BusyBoxDotNet.axd" verb="*" type="BusyBoxDotNet.ResourceHttpHandler, BusyBoxDotNet" /> 
     <add path="ChartAxd.axd" verb="*" type="Dundas.Charting.WebControl.ChartHttpHandler" validate="false" /> 
    </httpHandlers> 
    <httpModules> 
     <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    </httpModules> 
    <globalization culture="en-US" /> 
    <sessionState mode="StateServer" timeout="480" /> 
    <authentication mode="Forms"> 
     <forms cookieless="UseCookies" domain=".stuff.topleveldomain" enableCrossAppRedirects="true" name=".morestuff" timeout="480" /> 
    </authentication> 
    <machineKey validationKey=".." decryptionKey="..." validation="SHA1" /> 
    <customErrors mode="RemoteOnly" defaultRedirect="~/Public/ErrorPage.aspx"> 
     <error statusCode="404" redirect="~/Public/FileNotFound.htm" /> 
    </customErrors> 
    <membership defaultProvider="CustomAspNetSqlMembershipProvider"> 
     <providers> 
     <remove name="AspNetSqlMembershipProvider" /> 
     <add name="CustomAspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="Common" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="true" applicationName="stuff" requiresUniqueEmail="true" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" passwordFormat="Clear" maxInvalidPasswordAttempts="10000" passwordAttemptWindow="10" passwordStrengthRegularExpression="" /> 
     </providers> 
    </membership> 
    <roleManager enabled="true" defaultProvider="CustomAspNetSqlRoleProvider"> 
     <providers> 
     <clear /> 
     <add connectionStringName="Common" applicationName="stuff" name="CustomAspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" /> 
     </providers> 
    </roleManager> 
    <compilation debug="true"> 
     <assemblies> 
     <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" /> 
     <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> 
     <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> 
     <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> 
     <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> 
     <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> 
     </assemblies> 
    </compilation> 
    </system.web> 
    <!-- Configuration for pages that do not require authentication --> 
    <location path="public"> 
    <system.web> 
     <authorization> 
     <allow users="*" /> 
     </authorization> 
    </system.web> 
    </location> 
    <location path="Images/Misc"> 
    <system.web> 
     <authorization> 
     <allow users="*" /> 
     </authorization> 
    </system.web> 
    </location> 
    <location path="Images/Pics"> 
    <system.web> 
     <authorization> 
     <allow users="*" /> 
     </authorization> 
    </system.web> 
    </location> 
    <location path="stylesheet"> 
    <system.web> 
     <authorization> 
     <allow users="*" /> 
     </authorization> 
    </system.web> 
    </location> 
    <system.codedom> 
    <compilers> 
     <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4"> 
     <providerOption name="CompilerVersion" value="v3.5" /> 
     <providerOption name="WarnAsError" value="false" /> 
     </compiler> 
     <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4"> 
     <providerOption name="CompilerVersion" value="v3.5" /> 
     <providerOption name="OptionInfer" value="true" /> 
     <providerOption name="WarnAsError" value="false" /> 
     </compiler> 
    </compilers> 
    </system.codedom> 
    <system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <modules> 
     <remove name="ScriptModule" /> 
     <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    </modules> 
    <handlers> 
     <remove name="WebServiceHandlerFactory-Integrated" /> 
     <remove name="ScriptHandlerFactory" /> 
     <remove name="ScriptHandlerFactoryAppServices" /> 
     <remove name="ScriptResource" /> 
     <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     <add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    </handlers> 
    <defaultDocument> 
     <files> 
     <remove value="index.php" /> 
     <remove value="default.aspx" /> 
     <remove value="iisstart.htm" /> 
     <remove value="index.html" /> 
     <remove value="index.htm" /> 
     <remove value="Default.asp" /> 
     <remove value="Default.htm" /> 
     <add value="login.aspx" /> 
     </files> 
    </defaultDocument> 
    </system.webServer> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
</configuration> 
+0

ここにあなたの設定ファイルを投稿してください。 –

+0

確かに、何か別のものが必要な場合は教えてください – Grubsnik

+0

できるだけ簡単な小さなページを作成して問題を再現する可能性はありますか? 'FormsAuthentication'モジュールはログインページに私を送ります... – user1429080

答えて

2

は、(現在のページの実行を終了するかどうかを示し):

あなたが明示的に実行しながら、現在の要求を終了していない場合リダイレクトすると、実行フローが継続します。それはあなたの場合に起こり得ることです。パフォーマンスの問題のために

、最も一般的に使用されるリダイレクト方法、 Redirect(String)endresponseパラメータの値として falseで、 Redirect(String, Boolean)オーバーライド内部的に呼び出します。

ですから、

Response.Redirect("[login URL]",true); 

によって

Response.Redirect("[login URL]"); 

への呼び出し(複数可)を交換し、それはあなたの問題MSDNの

詳しい情報解くかどうかを確認しようとすることができます:

https://msdn.microsoft.com/en-us/library/a8wa7sdt(v=vs.110).aspx

+0

これは正しい解決策でした。どうやらIIS6とIIS8がこれを別々に処理していたか、または見逃したサーバー間にもう1つの違いがありました。 – Grubsnik

0

を上げていませんユーザーが認証されていない場合は、統合

APP POOL

+0

すでにクラシックモードで動作しています。 – Grubsnik

0

対クラスモードには、デフォルトのページとログインページを指定する価値があります。他のページでコードを実行しないようにします。私はHttpResponse.Redirect方法のendresponseパラメータについて考えさせる

<authentication mode="Forms"> 
     <forms loginUrl="~/Login" timeout="480" defaultUrl="~/" /> 
</authentication> 
関連する問題