Question

I have a website with login and register forms using custom HDI Membership provider where Users can login or register new account.

Now I have a desktop software and trying to have two forms for login and register where my users can able to login or register for user convenience and not by going to the website and make them register online.

So, I have these to know in order to go further.

1) Can I use HDI membership provider as I have used it in my web application? If so how can I do that?

As previously I have done and I faced many problems and still didn't get clarified here

2) If No, how do I make use in order to make use the same HDI Membership.

Finally I need to use the same database for my desktop software as well as my web application with all the possibilities (i.e. I need to validate each parameter of my membership class).

I am able to register the user but it is not using the Membership and I'm unable to know why it is not picking up the membership provider from the app.config file.

Once again I am providing my Users database Structure:

enter image description here

Était-ce utile?

La solution

You can use the standard membership provider in a Windows Forms application fairly easily.

However, without more details on the source of the HDI Membership provider, it will be difficult to provide exact instructions.

You can try the following instructions to see if they will work for you:

1) Add a reference to System.Web to your windows forms application.

2) Add an Imports System.Web.Security to the code file(s) where you want to use the provider.

3) Call the Membership methods as you do in the web, i.e. Memebership.ValidateUser(user, password).

4) Add a system.web block to your Windows Forms app.config file (within the configuration section) and then copy the membership block from your web.config file to this block. For example:

<configuration>
  <system.web>
    <membership defaultProvider="HDIMembershipProvider">
      <providers>
        <clear/>
        <add name="HDIMembershipProvider" type="frmStartup.HDIMembershipProvider, frmStartup"/>
      </providers>
    </membership>
  </system.web>
</configuration>

5) You will probably need to add a reference to the assembly, project, or code that contains the HDI Membership Provider.

Update

Your app.config has two problems:

1) The appSettings section must be exactly as follows (your current appSettings has "Application Name" as the key while your code uses "ApplicationName"):

<appSettings>
  <add key="ApplicationName" value="/gAnnotation" />
</appSettings>

2) The membership section must be exactly as follows (the type must specify the fully qualified type name followed by the name of the assembly the type lives in and the defaultProvider must match the name in the added provider):

<membership defaultProvider="HDIMembershipProvider">
  <providers>
    <clear/>
    <add name="HDIMembershipProvider" type="frmStartup.HDIMembershipProvider, frmStartup"/>
  </providers>
</membership>

If you modify your app.config exactly as shown above, your application will work (I have tested it and verified that creating a user and logging in works).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top