ees*_*ein 7 c# authorization owin asp.net-mvc-5
免责声明:这是我第一次使用ASP.NET MVC 5
我不知道为什么它不起作用.我无法让我的MVC5应用程序授权用户.我在以前的版本(2,3和4)中完成了这个,但我似乎无法在OWIN中使用它.
我正在使用启用了所需功能的本地IIS:

编辑:
我在IIS上使用SSL,在C#上使用RequireHttps
这是代码:
protected void Application_Start()
{
GlobalFilters.Filters.Add(new AuthorizeAttribute());
}
Run Code Online (Sandbox Code Playgroud)
Startup.Auth.cs
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/admin/account/login")
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseGoogleAuthentication();
Run Code Online (Sandbox Code Playgroud)
即使我使用全局授权,我试图"强制"它,看看这是不是问题:
public class HomeController : Controller
{
[Authorize]
public ActionResult Index()
{
return View();
}
}
Run Code Online (Sandbox Code Playgroud)
没有运气......我不确定OWIN是否有必要,但我甚至尝试过启用表单身份验证:
<authentication mode="Forms" />
Run Code Online (Sandbox Code Playgroud)
编辑[2]
好吧,我发现了问题...... IIS!最后!现在,有人会知道如何解决这个问题吗?在IIS上运行OWIN需要什么特别的东西吗?我现在可以工作,但很快我将不得不部署应用程序,并可能在服务器中遇到同样的问题...
我已经读过这些了:
如何使用AspNet.Identity使用Asp.Net MVC5 RTM位登录/验证用户?
有任何想法吗?
| 归档时间: |
|
| 查看次数: |
7547 次 |
| 最近记录: |