我正在从我创建的 VB.NET 调用一个服务堆栈 api - 它本质上是在您传递一个人的国籍时查找默认语言。
Dim response As BindingList(Of
Symphony_SystemFunctionsDefaultLanguageResponse)
Dim client As New JsonServiceClient(BASEURI)
response = client.[Get](New Symphony_SystemFunctionsDefaultLanguage() With {.NationalityCode = strNationality})
strNationality 是来自名为“ME/Kuw”的数据库中的代码(科威特语将返回阿拉伯语)
任何没有“/”或“\”的代码都会正确返回,所以我知道服务和调用可以正常工作,但是如果我使用代码,即 . “ME/Kuw”我得到了一个未找到的服务——它把 / 解释为一条路线,我试过制作字符串 URLencoded ,但它是同样的问题。
这是我的服务和响应代码 - 只要 .NationalityCode 中没有“/”,它就可以正常工作。
<Route("/SystemFunctions/DefaultLanguage/{NationalityCode}", "GET")>
Public Class Symphony_SystemFunctionsDefaultLanguage
Implements IReturn(Of BindingList(Of ymphony_SystemFunctionsDefaultLanguageResponse))
Private mvarNationalityCode As String
Public Property NationalityCode() As String
Get
NationalityCode = mvarNationalityCode
End Get
Set(ByVal Value As String)
mvarNationalityCode = Value
End Set
End Property
End Class
Public Class Symphony_SystemFunctionsDefaultLanguageResponse
Private mvarDefaultLanguage As String
Public Property DefaultLanguage() As String
Get
DefaultLanguage = mvarDefaultLanguage
End Get
Set(ByVal Value As String)
mvarDefaultLanguage = Value
End Set
End Property
End Class
和我获取数据的班级。
public Class Symphony_SystemFunctionsService
Inherits Service Public Function [get](request As Symphony_SystemFunctionsDefaultLanguage) As Object
Using dbcontext As New EntitiesModel1
Dim sqlQueryString As String = "proc_s_GetDefaultLanguage '" & request.NationalityCode & "'"
Dim response As IEnumerable(Of Symphony_SystemFunctionsDefaultLanguageResponse) =
dbcontext.ExecuteQuery(Of
Symphony_SystemFunctionsDefaultLanguageResponse)(sqlQueryString)
Return response
End Using
End Function
End Class
有什么建议我可以如何称呼它并允许在该数据中传递“/”?