无法让 Startup.cs 类在已部署的网站上运行

问题描述

我正在将 Webforms 网站从 sqlMembership 迁移到 Identity....因此,请阅读 Microsoft 发布的有关如何执行此操作的文章

文章https://docs.microsoft.com/en-us/aspnet/identity/overview/getting-started/adding-aspnet-identity-to-an-empty-or-existing-web-forms-project

每次部署时,都会出现 OWIN 错误

未在上下文中找到 owin.Environment 项

向启动添加了一些代码以确认它正在运行:

using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(WebApplicationEmptyCSharp.Startup))]

namespace WebApplicationEmptyCSharp
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.Run(async context =>
            {
                await context.Response.WriteAsync(DateTime.Now.ToString() + " My First OWIN App");
            });
        }
    }
}


这样我就可以确认它没有运行......在开发机器上运行良好,但不会在部署(托管)服务器上运行。

已确定 - Microsoft.Owin.Host.SystemWeb

在Bin目录下,检查!

按照建议安装:Microsoft.AspNet.Identity.Owin

身份验证模式设置为无

创建了一个只有一个页面的空项目,以测试它不是其他东西...相同的结果。真的很感谢这方面的帮助,把我剩下的头发撕掉!

这里是 web.config

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="None"></authentication>
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider,Microsoft.CodeDom.Providers.DotNetCompilerPlatform,Version=2.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /Nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider,PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /Nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
  <runtime>

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

      <dependentAssembly>

        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />

        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />

      </dependentAssembly>

    </assemblyBinding>

  </runtime>
</configuration>

感谢您的时间....并在此方面提供帮助.....

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)