【问题标题】:Not getting Startup.Auth file没有得到 Startup.Auth 文件
【发布时间】:2016-05-25 10:02:02
【问题描述】:

我正在尝试为我的网站安装 Steam 登录,但是在我在 nuget 包管理器控制台中完成安装之后,使用以下安装代码:Install-Package Owin.Security.Providers.Steam 我缺少我的Startup.Auth.cs。我究竟做错了什么? 该项目在没有“个人用户帐户”的情况下启动。

【问题讨论】:

  • 什么版本的 MVC?
  • @JamesP newVersion="5.2.3.0"

标签: c# asp.net-mvc owin


【解决方案1】:

Startup.Auth.cs 文件应该在您的App_Start 文件夹中。只需创建一个默认的 MVC Web 应用程序,并在 Change Authentication 选项下选择 Individual User Accounts 作为身份验证类型,看看它是如何实现的。

供参考:

using Microsoft.Owin;
using Microsoft.Owin.Security.Cookies;
using Owin;
using Owin.Security.Providers.Steam;

namespace WebApplication
{
    public partial class Startup
    {

        public void ConfigureAuth(IAppBuilder app)
        {
            //other Config

            app.UseSteamAuthentication("your API key");
        }
    }
}

请参阅here,了解如何添加 Steam 登录按钮。

编辑: 另请参阅here Adding MVC 5 Identity to our Existing Project.

您可能需要将 startup.cs 添加到项目的根目录:

using Microsoft.Owin;
using Owin;

[assembly: OwinStartupAttribute(typeof(WebApplication1.Startup))]
namespace WebApplication1
{
    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);
        }
    }
}

【讨论】:

猜你喜欢
  • 2018-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-02
  • 2021-05-24
  • 1970-01-01
相关资源
最近更新 更多