Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > ASP.Net > ASP.NET Authentication + web service


Reply
 
Thread Tools Display Modes
  #1  
Old 03-25-2010, 07:59 AM
ivanzg ivanzg is offline
Newcomer
 
Join Date: Dec 2009
Posts: 1
Default ASP.NET Authentication + web service


Hi,

I have asmx web service with this webmethod:

Code:
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

HTML Code:
	<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?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->