名称configureauth不存在 [英] the name configureauth does not exist

查看:566
本文介绍了名称configureauth不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要这个教程
http://httpjunkie.com/2013/311/adding-mvc-5-identity-to-an-existing-project/
,但显示了我一个错误
错误5'ConfigureAuth'这个名字并不在目前的情况下结果$ b $存在b本是我startup.cs类

 使用系统; 
使用System.Collections.Generic;
使用System.Linq的;
使用的System.Web;

使用Microsoft.Owin;
使用Owin;

[总成:OwinStartupAttribute(typeof运算(TicketSystem.Startup))]
命名空间TicketSystem
{
公共部分类启动
{
公无效配置(IAppBuilder应用程序)
{
ConfigureAuth(应用程序);
}



}
}

这是Startup.Auth.cs

 使用系统; 
使用System.Collections.Generic;
使用System.Linq的;
使用的System.Web;

使用System.Web.Mvc;

使用Microsoft.AspNet.Identity;
使用Microsoft.Owin;使用Microsoft.Owin.Security.Cookies
;
使用Owin;
命名空间TicketSystem.App_Start
{
公共部分类启动
{

//有关配置身份验证的详细信息,请访问http://去.microsoft.com / fwlink /?LINKID = 301864
公共无效ConfigureAuth(IAppBuilder应用程序)
{
//使应用程序能够使用cookie来存储信息,在用户$ b的有符号$ b app.UseCookieAuthentication(新CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LOGINPATH =新PathString(/帐号/登录)
});
//使用cookie来临时存储有关用户记录的信息与第三方登录提供
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

//取消注释以下行来实现与第三方登录提供商
//app.UseMicrosoftAccountAuthentication(
//的clientId登录:,
// clientSecret:);

//app.UseTwitterAuthentication(
// consumerKey:,
// consumerSecret:);

//app.UseFacebookAuthentication(
// APPID:,
// appSecret:);

//app.UseGoogleAuthentication();
}
}
}


解决方案

您必须在这两个文件不同的命名空间:命名空间TicketSystem.App_Start 命名空间TicketSystem 。确保它们是相同的。或者可以选择添加using语句:在你的startup.cs类使用TicketSystem.App_Start
如果检查例子中,你会看到这两个文件都使用相同的命名空间(命名空间MVC5FullApp


i'm trying this tutorial http://httpjunkie.com/2013/311/adding-mvc-5-identity-to-an-existing-project/ but is shows me an error Error 5 The name 'ConfigureAuth' does not exist in the current context
this is my startup.cs class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using Microsoft.Owin;
using Owin;

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



      }
    }

this is Startup.Auth.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Web.Mvc;

using Microsoft.AspNet.Identity;
using Microsoft.Owin;
using Microsoft.Owin.Security.Cookies;
using Owin;
namespace TicketSystem.App_Start
{
    public partial class Startup
    {

        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });
            // Use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Uncomment the following lines to enable logging in with third party login providers
            //app.UseMicrosoftAccountAuthentication(
            // clientId: "",
            // clientSecret: "");

            //app.UseTwitterAuthentication(
            // consumerKey: "",
            // consumerSecret: "");

            //app.UseFacebookAuthentication(
            // appId: "",
            // appSecret: "");

            //app.UseGoogleAuthentication();
        }
    }
}

解决方案

You have different namespaces in both files: namespace TicketSystem.App_Start and namespace TicketSystem. Make sure they are the same. Or alternatively add using statement: using TicketSystem.App_Start in your startup.cs class. If you check the example you'll see that both files are using the same namespace (namespace MVC5FullApp)

这篇关于名称configureauth不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆