1

我正在尝试为 ASP.net webforms oracle 项目实现自定义配置文件类。

这是我使用 VB.net 的基本配置文件类

Public Class BaseProfile
    Inherits ProfileBase

    Public Shared Function GetUserProfile(ByVal un As String) As BaseProfile
        Return TryCast(Create(un), BaseProfile)
    End Function

    Public Shared Function GetUserProfile()
        Return TryCast(Create(Membership.GetUser().UserName), BaseProfile)
    End Function


    Public Property PreviousPage() As String
        Get
            Return TryCast(MyBase.Item("previouspage"), String)
        End Get
        Set(value As String)
            MyBase.Item("previouspage") = value
        End Set
    End Property

End Class

这是我尝试使用课程的方式

        If userProfile Is Nothing Then
            userProfile = BaseProfile.GetUserProfile()

        End If

        userProfile.PreviousPage = Request.UrlReferrer.ToString()

这是我的 web.config 配置文件标签的设置方式

<profile defaultProvider="SqlProvider" inherits="AppNamespace.BaseProfile">
  <providers>
    <add name="SqlProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="OraMembershipConnection"  applicationName="AppNamespace" />

   <add name="OraMembershipProvider" type="Oracle.Web.Profile.OracleProfileProvider",  Oracle.Web,  Culture=neutral" connectionStringName="OraMembershipConnection" ApplicationName="AppNamespace"/>
  </providers>

</profile>

当我使用 defaultProvider="SqlProvider" 时,它允许我创建我的 BaseProfile 类,但是当我尝试设置一个属性时,我收到一条错误消息

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

当我使用 defaultProvider="OraMembershipProvider" 时,我在类初始化时收到此错误

Provider must implement the class 'System.Web.Profile.ProfileProvider'. (C:\development\proj\web.config line 177)

我试图在网上找到这方面的文档。当我尝试使用 OracleProfileProvider 继承 BaseProfile 时,我不能再使用 Create 函数,因为它们在该类中不存在。

我需要一些指导或建议来弄清楚我做错了什么!谢谢。

是的,“OraMembershipConnection”是适用于项目其他部分的有效工作连接。

4

0 回答 0