ASP.NET OWIN WebForms的需要授权的所有页面 [英] ASP.NET OWIN WebForms require authorization all pages

查看:95
本文介绍了ASP.NET OWIN WebForms的需要授权的所有页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建与Visual Studio 2013新的ASP.NET应用程序的WebForms,更新2.然后我更新了所有的Nu​​Get软件包,并删除了所有的OAuth的东西,因为我只是想的形式的身份验证,这是我什么熟悉。

I created a new ASP.NET WebForms application with Visual Studio 2013, Update 2. Then I updated all of the NuGet packages and removed all of the OAuth stuff since I just want "forms" authentication, which is what I'm familiar with.

我要的是配置OWIN / ASP.NET身份框架的使所有页面需要授权,包括默认的页面 - 因此用户应该看到的第一个页面是登录页面。什么是做到这一点的正确方法?我无法找到在互联网上,显示如何使用OWIN / ASP.NET身份获得一个WebForms的页面上的任何资源。

What I want is to configure the OWIN/ASP.NET Identity framework so that all pages require authorization, including default pages - so the first page a user should see is the Login page. What is the correct way to do this? I cannot find any resources on the Internet that show how to secure a WebForms page with OWIN/ASP.NET Identity.

我添加下面的XML我的主要web.config文件的底部,我得到一个错误:

I added the following XML to the bottom of my main web.config file, I get an error:

<authorization>
  <deny users="?"/>
</authorization>

该错误是:请求的页面无法访问,因为该页的相关配置数据无效

推荐答案

添加以下过滤器为默认App_Start / FilterConfig.cs文件(在RegisterGlobalFilters法)的伎俩:

Adding the following filter to the default App_Start/FilterConfig.cs file (in the RegisterGlobalFilters method) did the trick:

filters.Add(new AuthorizeAttribute());

这篇关于ASP.NET OWIN WebForms的需要授权的所有页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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