2016-06-10 37 views
1

我有一個Web表單應用程序,我需要整合Facebook,谷歌和Twitter的登錄,但我發現所有的教程是我的解決方案沒有Startup.auth.cs ,然後當我實現一個歐文班,並嘗試致電Oauth2沒有MVC在webforms

app.UseCookieAuthentication 

我得到的錯誤,owin.iappbuilder不包含定義。

我正在使用4.5.net框架,並沒有MVC,所以任何幫助將是偉大的。

我一直停留在這個錯誤相當長的一段時間,以便讓這個過去的幫助或方向的教程將是一個極大的安慰

回答

1

關於如何做到這一點的教程參見here。你想要這部分:

using Microsoft.AspNet.Identity; 
using Microsoft.Owin; 
using Microsoft.Owin.Security.Cookies; 
using Owin; 

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

namespace WebFormsIdentity 
{ 
    public class Startup 
    { 
     public void Configuration(IAppBuilder app) 
     { 
     // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888 
     app.UseCookieAuthentication(new CookieAuthenticationOptions 
     { 
      AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, 
      LoginPath = new PathString("/Login") 
     }); 
     } 
    } 
} 
+0

你如何使用這種方法通過Facebook進行身份驗證?因爲當我包括app.UseFacebookAuthentication(我得到一個錯誤,說它不存在 – user3376687

+0

)你需要添加'Owin.Facebook'包並使用Microsoft.AspNet添加(請注意這來自內存,可能不是確切的)。 Owin.Facebook' –

+0

工作了一個魅力,謝謝:) – user3376687