使用正确的凭据登录后返回登录操作

时间:2017-07-12 11:42:46

标签: c# asp.net asp.net-mvc asp.net-routing

我的MVC应用程序似乎在生产环境中表现得有些奇怪,尽管在本地计算机上工作正常。这是我的情景:

  1. 用户进入我的网站
  2. 用户未登录,因此重定向到登录页面
  3. 用户输入凭据
  4. 用户被重定向到我的页面页面,显示他们的信息
  5. 如果在本地调试,这一切都可以正常工作,但这是生产环境中的场景:

    1. 用户进入我的网站
    2. 用户未登录,因此重定向到登录页面
    3. 用户输入凭据
    4. 应用程序尝试将用户重定向到我的页面,但会返回状态为的回复:
    5.   

      302发现

      1. 用户被重定向到登录页面
      2. 在本地调试此应用程序,登录操作的响应(如果成功)不是" 302 Found"但是

          

        200获取

        我通过文件系统发布网站,并期望行为与本地调试完全相同。

        可能的原因是什么,以及为什么会发生这种情况?

        • 登录网址:mydomain.com
        • 我的网页网址:mydomain.com/mypage

        的Web.config

        <?xml version="1.0" encoding="utf-8"?>
        <!--
          For more information on how to configure your ASP.NET application, please visit
          http://go.microsoft.com/fwlink/?LinkId=301880
          -->
        <configuration>
          <configSections>
            <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
            <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
          </configSections>
          <connectionStrings>
            <add name="SomeConnection" connectionString="SomeConnectionString" />
            <add name="SomeConnection2" connectionString="SomeConnectionString2" />
          </connectionStrings>
          <appSettings>
            <add key="webpages:Version" value="3.0.0.0" />
            <add key="webpages:Enabled" value="false" />
            <add key="ClientValidationEnabled" value="true" />
            <add key="UnobtrusiveJavaScriptEnabled" value="true" />
            <add key="vs:EnableBrowserLink" value="true" />
          </appSettings>
          <!--
            For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
        
            The following attributes can be set on the <httpRuntime> tag.
              <system.Web>
                <httpRuntime targetFramework="4.6" />
              </system.Web>
          -->
          <system.web>
            <authentication mode="None" />
            <compilation debug="true" targetFramework="4.6.1">
              <assemblies>
                <add assembly="System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
                <add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
                <add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
              </assemblies>
              <buildProviders>
                <add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
              </buildProviders>
            </compilation>
            <httpRuntime targetFramework="4.5" maxRequestLength="1048576" relaxedUrlToFileSystemMapping="true" />
            <customErrors mode="Off" />
            <httpModules>
              <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
            </httpModules>
          </system.web>
          <system.webServer>
            <staticContent>
              <remove fileExtension=".json" />
              <mimeMap fileExtension=".json" mimeType="application/json; charset=UTF-8" />
              <remove fileExtension=".woff" />
              <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
              <remove fileExtension=".woff2" />
              <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
            </staticContent>
            <modules>
              <remove name="FormsAuthentication" />
              <remove name="ApplicationInsightsWebTracking" />
              <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
            </modules>
            <handlers>
              <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
              <remove name="OPTIONSVerbHandler" />
              <remove name="TRACEVerbHandler" />
              <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
            </handlers>
            <validation validateIntegratedModeConfiguration="false" />
          </system.webServer>
          <runtime>
            <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
              <dependentAssembly>
                <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
                <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
              </dependentAssembly>
              <dependentAssembly>
                <assemblyIdentity name="Microsoft.AI.Agent.Intercept" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
              </dependentAssembly>
            </assemblyBinding>
          </runtime>
          <entityFramework codeConfigurationType="SomeProject.Infrastructure.SqlAzureConfiguration, SomeProject.Infrastructure">
            <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
              <parameters>
                <parameter value="mssqllocaldb" />
              </parameters>
            </defaultConnectionFactory>
            <providers>
              <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
            </providers>
          </entityFramework>
          <system.diagnostics>
            <trace autoflush="true" indentsize="0">
              <listeners>
                <add name="myAppInsightsListener" type="Microsoft.ApplicationInsights.TraceListener.ApplicationInsightsTraceListener, Microsoft.ApplicationInsights.TraceListener" />
              </listeners>
            </trace>
          </system.diagnostics>
        </configuration>
        

1 个答案:

答案 0 :(得分:0)

找到我的问题

这非常特定于我的场景,但显然我的_LoginPartial.cshtml未发布到远程站点。这导致网站无法呈现,返回到我登录的主页,因此没有单独的登录页面,因为没有登录的人不应该输入该网站。

发布_LoginPartial.cshtml后,所有内容都能够呈现,我的网站现在可以按预期再次运行。