views:

831

answers:

2

Hello,


Say I create CreateUserWizard control and use AspNetSqlMembershipProvider (defined in machine.config) as a default membership provider. Assuming I change default provider's requiresQuestionAndAnswer attribute to false, then CreateUserWizard control template should not be required to provide Question and Answer fields. But if I request the page via IIS7 I get the following exception:

CreateUserWizard1: CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Question for the security question, this is required if your membership provider requires a question and answer.

A) The above exception suggests that when requesting a page via IIS7, runtime doesn’t use AspNetSqlMembershipProvider (defined in machine.config)as a default provider?! If true, then why is that?

B) And where can I find the definition for IIS7’s default provider?


thanx


EDIT:

Here is <Membership> element in machine.config file:

    <membership>
     <providers>
  <add name="AspNetSqlMembershipProvider" 
         type="System.Web.Security.SqlMembershipProvider, System.Web,Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
         connectionStringName="LocalSqlServer" 
         enablePassswordRetrieval="false" 
         requiresQuestionAndAnswer="false" 
         applicationName="/" requiresUniqueEmail="false" 
         passwordFormat="Hashed" maxInvalidPasswordAttempts="5" 
         minRequiredPasswordLength="7" 
         minRequiredNonalphanumericCharacters="0" 
         passwordAttemptWindow="10" 
         passwordStrengthRegularExpression=""/>
    </providers>
   </membership>


Are you changing the machine.config for the correct version of runtime?

I'm not sure what you mean by that. I'm running Asp.Net 3.5, which I think uses Asp.Net engine version 2.0.50727. Thus I manipulated machine.config located inside C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG

+1  A: 

IIS7 uses its own configuration file located at %windir%\System32\inetsrv\config\applicationHost.config. However, this file deals with IIS7 specific configuration (e.g. <system.webServer>) and not <system.web> stuff. I believe those are still read from machine.config and web.config files. Indeed, the default value (specified in machine.config) for requiresQuestionAndAnswer for the AspNetSqlMembershipProvider is true on my machine.

UPDATE:

Under a 64 bit OS, a .NET application can either run on a 32 bit CLR in WOW64 mode or natively run under x64 mode. Each .NET framework instance has its own set of config files and ignores all other configuration files.

IIS7 on a 64 bit OS runs applications in 64 bit mode by default. You can, however, set an application pool to run as a 32 bit WOW64 process (enable32BitAppOnWin64, which you can set in Advanced Settings dialog for an application pool in IIS7 manager). If you do that, obviously it'll use settings from 32 bit machine.config. The reason VS Web server uses 32 bit machine.config is exactly this: it runs as a WOW64 process.

Mehrdad Afshari
Any idea why on my machine default provider ( defined inside machine.config ) is ignored?
SourceC
SourceC: Could you post the <membership> tag in your machine.config? Are you changing the `machine.config` for the correct version of runtime?
Mehrdad Afshari
hi - my reply is in the original post, which I edited. I appreciate it
SourceC
SourceC: Are you running a 64 bit OS?
Mehrdad Afshari
Yes, I'm running 64 bit Windows server 2008 (trial version). Is that of any significance?
SourceC
Yep, Change the `machine.config` file in "%windir%\Microsoft.NET\Framework64\v2.0.50727\CONFIG" and test.
Mehrdad Afshari
Yay, it works now. :D In case you're still reading this:A) why do the two servers ( IIS7 and VS's build-in server ) use two different machine.config files? B) And more importantly, when requesting a page via IIS7, does runtime only use settings in machine.config for 64bit version or does it also "borrow" certain settings from machine.config for 32bit version? In any case, I really appreciate your help
SourceC
SourceC: I've updated the answer. B) The 32 bit machine.config is completely ignored in 64 bit mode.
Mehrdad Afshari
thanx mate. You're a life saver
SourceC
+1  A: 

Where exactly did you make the change on "requiresQuestionAndAnswer"? If it is on machine.config, IIS should honor that.

Lex Li
I made the change in machine.config
SourceC