asp.net验证 - 使用来自web.config文件的凭据 - 问题 [英] asp.net authentication - use credentials from web.config - problem

查看:128
本文介绍了asp.net验证 - 使用来自web.config文件的凭据 - 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个是给我一个简单的问题头疼了两天。

I have a simple problem which is giving me headaches for a couple of days.

我已经创建了登录控制非常简单的应用。我保持用户数据在web.config文件:

I've created very simple application with login control. I keep user data in web.config file:

<authentication mode="Forms">
    <forms name=".RzeskoLoginCookie">
        <credentials passwordFormat="Clear">
    	     <user name="test" password="test"/>
    	</credentials>
    </forms>
</authentication>

我将部署这个简单的网站到IIS上,我不想使用SQL Server的计算机上。

I will deploy this simple website to IIS on computer on which I do not want to use SQL Server.

我的登录按钮事件是这样的:

My login button event looks like this:

protected void Login1_LoggingIn(object sender, LoginCancelEventArgs e)
{
    if(FormsAuthentication.Authenticate(Login1.UserName, Login1.Password))
    {
        FormsAuthentication.RedirectFromLoginPage(Login1.UserName, Login1.RememberMeSet);
    }
}

现在的问题:

当我正在上内置的Web服务器VS2008网站,一切工作正常(我可以登录)。当我将网站复制到IIS我经常收到这恼人的错误(我后,点击登录按钮):

When I am running a website on VS2008 built in webserver, everything works fine (I can log in). When I copy my website to IIS I am constantly getting this annoying error (after I click Login button):

无法生成的用户实例
  SQL服务器由于故障
  检索用户的本地
  应用数据路径。请
  确保用户具有一个本地用户简档
  在电脑上面。连接将
  被关闭。

Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.

我也观察到,在我的App_Data文件夹正在创造一些奇怪的文件。

I also observed that in my App_Data folder some weird files are being created.

要总结一下。我想实现的是从使用web.config文件中的用户凭据,而不使用SQL Server。

To sum up. What I want to achieve is to use user credentials from web.config file, without using sql server.

我想AP preciate任何帮助

I'd appreciate any help

亲切的问候
PK

Kind Regards PK

推荐答案

从的 MSDN 页面的登录控制:

*

Login控件使用会员
  供应商获取用户凭据。
  除非您否则,指定
  登录控件使用默认
  在定义的成员资格提供
  Web.config文件。要指定
  不同的供应商,集
  的MembershipProvider属性之一
  成员资格提供程序名称定义
  在应用程序的Web.config文件。
  欲了解更多信息,请参阅会员
  供应商。

The Login control uses a membership provider to obtain user credentials. Unless you specify otherwise, the Login control uses the default membership provider defined in the Web.config file. To specify a different provider, set the MembershipProvider property to one of the membership provider names defined in your application's Web.config file. For more information, see Membership Providers.

*

默认成员资格提供程序是在 AspNetSqlProvider 它使用一个SQL Server数据库作为其用户存储。

The default Membership provider is the AspNetSqlProvider which uses a SQL Server database as its user store.

如果您想提供一个自定义的验证程序,您可以编写自己的定制会员提供商或处理的 OnAuthenticate 方法来提供自己的验证逻辑。

If you want to provide a custom authentication routine, you can either write your own custom Membership provider or handle the OnAuthenticate method of the Login control to provide your own authentication logic.

这篇关于asp.net验证 - 使用来自web.config文件的凭据 - 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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