ASP.NET Authentication + web service

ivanzg
03-25-2010, 07:59 AM
Hi,

I have asmx web service with this webmethod:

Public Class AuthWebService
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function Authenticate(ByVal Username As String, ByVal Password As String) As Boolean

If FormsAuthentication.Authenticate(Username, Password) Then
FormsAuthentication.SetAuthCookie(Username, False)
Return True
End If

Return False

End Function


User credentials are saved in SQL server database AspNetDb. This is part of my web.config


<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Initial Catalog=aspnetdb; Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
</connectionStrings>

<authentication mode="Forms">
<forms cookieless="UseCookies"
loginUrl="~/SL_AuthenticationTestPage.aspx" />
</authentication >

<membership defaultProvider="DefaultMembershipProvider">
<providers>
<clear/>
<add name="DefaultMembershipProvider"
connectionStringName="LocalSqlServer"
applicationName="/SL_Authentication"
minRequiredNonalphanumericCharacters="0"
minRequiredPasswordLength="3"
passwordFormat="Clear"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</membership>


When I open ASP.NET Configuration page I can see users from AspNetDb database, but when I open asmx in browser and enter correct username and password the result is False... If I add users directly in web.config, web service is working correctly... Is there something that must be enabled to use asp.net authentication from asmx web service?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum