在C#中阅读Web.config身份验证模式 [英] Read Web.config Authentication Mode in C#

查看:115
本文介绍了在C#中阅读Web.config身份验证模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我需要从web.config中读取身份验证模式.我正在使用 Forms身份验证模式.
此处 FormAuthentication 是Web服务,其中我使用的方法为身份验证.
它接受三个参数用户名密码身份验证模式.
要获得身份验证模式,我使用了 Httpcontext ,如下代码段所示
,但这里的问题始终是我将authmode变量设为"false" ;值,尽管它是表单身份验证.

Web.config:

Hi,

I have an requirement of reading authentication mode from web.config.I am using Forms authentication mode.
Here FormAuthentication is Webservice and in that i have a method as Authentication.
It accepts three parameters Username,password and authentication mode.
to get authentication mode i used Httpcontext as given below in code snippet
but the issue here is always i get authmode variable as 'false" value eventhough it is form authentication.

Web.config:

<authentication mode="Forms">
<forms name="LoginUserAuthentication" loginUrl="LoginPage.aspx"  timeout="30" protection="All" path="/">
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>


推荐答案

ASP.NET问题应在此处提出: http://forums.asp.net/

但是,既然你问了,就去吧:
ASP.NET question should be asked here: http://forums.asp.net/

But since you asked, here ya go:
            AuthenticationSection yourAS = System.Configuration.ConfigurationManager.GetSection("system.web/authentication") as AuthenticationSection;
            //yourAS.Mode


这篇关于在C#中阅读Web.config身份验证模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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