ASP Membership Odd Problem

你说的曾经没有我的故事 提交于 2019-12-10 16:14:12

问题


I am using the Membership API in ASP .NET and I have encountered the following problem on my staging server. The application works fine on my local machine. The data tables are stored on a SQL Server. Both my local and staging server point to the same DB server. When I deploy to my staging server I get the following error:

 Parser Error Message: The connection name 'OraAspNetConString' was not 
 found in the applications configuration or the connection string is empty. 

    Line 135:    <roleManager>
    Line 136:      <providers>
    Line 137:        <add name="OracleRoleProvider" 

type="Oracle.Web.Security.OracleRoleProvider, Oracle.Web, Version=2.111.6.20,
Culture=neutral, PublicKeyToken=89b483f429c47342" 
connectionStringName="OraAspNetConString" applicationName="" />
    Line 138:        <add name="AspNetSqlRoleProvider"   
connectionStringName="LocalSqlServer" applicationName="/" 
type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, 
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    Line 139:        <add name="AspNetWindowsTokenRoleProvider" 
applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, 
System.Web, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a" />


Source File: 
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config
    Line: 137 

I do not know why it is even trying to do anything with Oracle, my web.config does not contain anything associated with Oracle.

Does anyone have any insight into why this is happening?

[Edit] On my local machine's machine.config I do not have the OracleRoleProvider key. But my staging server does. If that helps.


回答1:


Old question here but I just ran into it and wanted to share some more details.

First, the easiest solution if you need to do a <clear/> in your connectionStrings block is to add a blank OraAspNetConString connectionstring entry back into your web.config:

<connectionStrings>
    <clear />
      <add name="OraAspNetConString" connectionString=" "/>    
</connectionStrings>

What happens when you install the Oracle .NET package on any of your machines is it installs a ton of different providers into your machine.config along with the OraAspNetConString as a machine-level connectionString. The <clear/> element gets rid of that OraAspNetConString and thanks to Oracle's machine.config additions all of the other Oracle providers loaded by default are crashing when they can't find the connectionString.

The other answer here where you explored using the element for membership providers didn't work because most of the other oracle providers added in the machine.config are still going to be looking for that OraAspNetConString so clearing just that one provider doesn't help you.

These are all the providers they installed into my machine.config:

<membership><providers>
    <add name="OracleMembershipProvider" type="Oracle.Web.Security.OracleMembershipProvider, Oracle.Web, Version=4.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" connectionStringName="OraAspNetConString" applicationName="" />
</providers></membership>
<profile><providers>
    <add name="OracleProfileProvider" type="Oracle.Web.Profile.OracleProfileProvider, Oracle.Web, Version=4.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" connectionStringName="OraAspNetConString" applicationName=""/>
</providers></profile>
<roleManager><providers>
    <add name="OracleRoleProvider" type="Oracle.Web.Security.OracleRoleProvider, Oracle.Web, Version=4.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" connectionStringName="OraAspNetConString" applicationName=""/>
</providers></roleManager>
<siteMap><providers>
    <add name="OracleSiteMapProvider" type="Oracle.Web.SiteMap.OracleSiteMapProvider, Oracle.Web, Version=4.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" connectionStringName="OraAspNetConString" applicationName="" securityTrimmingEnabled="true"/>
</providers></siteMap>
<webParts>
  <personalization>
    <providers>
      <add name="OraclePersonalizationProvider" type="Oracle.Web.Personalization.OraclePersonalizationProvider, Oracle.Web, Version=4.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" connectionStringName="OraAspNetConString" applicationName=""/>
    </providers>
  </personalization>
</webParts>
<healthMonitoring><providers>
    <add name="OracleWebEventProvider" type="Oracle.Web.Management.OracleWebEventProvider, Oracle.Web, Version=4.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" connectionStringName="OraAspNetConString" buffer="true" bufferMode="OracleNotification"/>
</providers></healthMonitoring>

So if you didn't want to add the blank OraAspNetConString you'd have to make sure that you either <clear/> every one of the following Oracle Providers or go in and add a <remove name=x /> element to each provider class like this:

<membership><providers>
    <remove name="OracleMembershipProvider" />
</providers></membership>
<profile><providers>
    <remove name="OracleProfileProvider" />
</providers></profile>
<roleManager><providers>
    <remove name="OracleRoleProvider" />
</providers></roleManager>
<siteMap><providers>
    <remove name="OracleSiteMapProvider" />
</providers></siteMap>
<healthMonitoring><providers>
    <remove name="OracleWebEventProvider" />
</providers></healthMonitoring>

I never dealt with any siteMap or Health Monitoring code in my web app but I still had to manually add these <remove/> elements for the different providers in my web.config or something would crash looking for an OraAspNetConString connection string that wasn't there.




回答2:


You need to define your own provider in your config file for example here is a membership provider:

    <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
        <providers>
            <clear/>
            <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MyConnection" applicationName="MyApp"/>
        </providers>
    </membership>

Basically this will remove all the providers defined at the system level, This is why we are clearing, then you define your new providers. If you need the providers at the system level you can define your own as the default, or in your app code specifically request your provider.




回答3:


This error is saying you have that in the machine.conf not web.config.




回答4:


Simply add an empty ConnectionString for "OraAspNetConString" worked for me

<connectionStrings>
    <clear />
    <add name="OraAspNetConString" connectionString=" "/>
    .................. your other connectionstrings goes here .....
</connectionStrings>


来源:https://stackoverflow.com/questions/651385/asp-membership-odd-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!