0

I've created a class and placed in the App_Code folder. When I try to access from the Web.config file, I'me getting an exception: The profile default provider was not found.

<profile defaultProvider="SqlProvider" inherits="CustomUserProfile">
    <providers>
      <clear />
      <add name="ProfileProvider"
       connectionStringName="LocalSqlServer"
       type="System.Web.Profile.SqlProfileProvider, 
       System.Web, Version=4.0.0.0, 
       Culture=neutral, 
       PublicKeyToken=b03f5f7f11d50a3a"
       description="SqlProfileProvider extra fields"
       applicationName="/" />
    </providers>
  </profile>

When I add this code:

<profile defaultProvider="SqlProvider" inherits="MyApp.App_Code.CustomUserProfile">

I'm getting a different error.

Compiler Error Message: BC30002: Type 'MyApp.App_Code.CustomUserProfile' is not defined.

I'd like to know what's the namespace for a file located in the App_Code folder?

Thank for helping.

Richard77
  • 20,343
  • 46
  • 150
  • 252
  • try MyApp.CustomUserProfile – cableload Apr 04 '16 at 21:24
  • Removing `App_Code` puts me back the previous error, which is: `The profile default provider was not found.` – Richard77 Apr 04 '16 at 21:27
  • 1
    Why not add a namespace around your class so that you know explicitly what it will be? – mason Apr 04 '16 at 21:32
  • Wrapping up the class inside an explicit namespace didn't solve the problem. I'm still getting the same error: `The profile default provider was not found.` – Richard77 Apr 04 '16 at 21:39
  • Does [unable to call App_Code class from a code-behind](http://stackoverflow.com/a/14206137/296861) relate to your question? – Win Apr 04 '16 at 22:12

1 Answers1

1

The DefaultProvider should match the name added in providers, like this:

<profile defaultProvider="ProfileProvider" inherits="CustomUserProfile">
Poul Bak
  • 10,450
  • 5
  • 32
  • 57
  • I've two makes two changes. 1) as suggested some other places, change the build action to compile 2) prepend the name of the project to the name of the class like this `inherits="MyApp.CustomUserProfile"`. Besides that, the big problem is what you pointed out, i.e. I did just copy/paste without paying attention to the content. The default provider name should be the same as the provider I've added. Thank you so much. – Richard77 Apr 05 '16 at 14:48