c# - 没有获取 Startup.Auth 文件

标签 c# asp.net-mvc owin

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

最佳答案

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);
        }
    }
}

关于c# - 没有获取 Startup.Auth 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37433790/

相关文章:

asp.net-mvc - 如何使用 IoC、DI 和 MVC 连接 View 模型上的列表/集合?

c# - 编辑时禁用用户名验证

ajax - MVC 部分 View 返回整个页面而不仅仅是部分页面

c# - 是什么导致错误 "Looks like you forgot to register the http module CaSTLe.MicroKernel.Lifestyle.PerWebRequestLifestyleModule"?

c# - 使用 MVC5 和 OWIN 的自定义标识

c# - 如何将事件处理程序添加到 DataGrid 按钮(该按钮是基于数据库动态添加的)?

c# - C# Web MVC 5项目中连续阅读SslStream

c# - 如何在 asp.net mvc 身份上设置自定义身份验证?

c# - 使用索引数组反序列化 JSON

c# - 从局部 View 向页面的 <head> 添加 CSS 引用