好的我有一个奇怪的,我现在在WSS 3.0中有一个SharePoint WebPart,它使用VB.NET和HttpWebRequest对象查询Yahoo Traffic的REST接口。但是我一直收到来自雅虎的错误消息,说我未经授权,经过进一步检查,我注意到它将以下网址传递给雅虎: http://local.yahooapis.com/MapsService/V1/trafficData?appid=&city=&state=&radius=20
私有_AppID为字符串
<Personalizable(True), WebBrowsable(True), WebDisplayName("Yahoo App ID"), WebDescription("Yahoo Application ID")> _
Public Property AppID() As String
Get
Return _AppID
End Get
Set(ByVal value As String)
_AppID = value
End Set
End Property
Private _City As String
<Personalizable(True), WebBrowsable(True), WebDisplayName("City"), WebDescription("City")> _
Public Property City() As String
Get
Return _City
End Get
Set(ByVal value As String)
_City = value
End Set
End Property
Private _State As String
<Personalizable(True), WebBrowsable(True), WebDisplayName("State"), WebDescription("State")> _
Public Property State() As String
Get
Return _State
End Get
Set(ByVal value As String)
_State = value
End Set
End Property
Private _radius As String = "-1"
<Personalizable(True), WebBrowsable(True), WebDisplayName("Radius (in miles)"), WebDescription("Radius in Miles")> _
Public Property Radius() As String
Get
If _radius = "-1" Then
Return "20"
Else
Return _radius
End If
End Get
Set(ByVal value As String)
_radius = value
End Set
Dim Url As String = ""
Try
Dim aDoc As New d.DataSet
Url = "http://local.yahooapis.com/MapsService/V1/trafficData?appid=" & Me.AppID & "&city=" & Me.City & "&state=" & Me.State & "&radius=" & Me.Radius
Dim aRequest As n.HttpWebRequest = CType(n.HttpWebRequest.Create(Url), n.HttpWebRequest)
Dim aResponse As n.HttpWebResponse
aResponse = CType(aRequest.GetResponse(), n.HttpWebResponse)
If aResponse.StatusCode <> Net.HttpStatusCode.OK Then
Throw New Exception("Server Returned This Code" & aResponse.StatusCode.ToString() & aResponse.StatusDescription)
End If
aDoc.ReadXml(aResponse.GetResponseStream())
Return aDoc
Catch ex As Exception
System.Diagnostics.EventLog.WriteEntry("YahooTrafficUtil", ex.Message & ex.StackTrace & Url)
Dim aContext As System.Web.HttpContext = System.Web.HttpContext.Current
aContext.Trace.Warn(ex.ToString() & ex.StackTrace)
childException = ex
Return Nothing
这是在我无法访问调试的测试服务器上,但是我的开发服务器检查确定,一切都通过,没问题。
AppId,City和State参数是我的SharePoint Web部件中列出的参数,但出于某种原因,尽管我填充了这些Web部件,但它们仍然是空白的。来自人群的任何想法?谢谢!
答案 0 :(得分:1)
您是否尝试过不同的WebPartStorage(Storage.Personal)[默认为Storage.Personal]属性装饰?
我假设错误是存储属性而不是代码。
答案 1 :(得分:1)
发现它,它实际上是default.master文件的一个愚蠢的问题,我终于设法弄清楚当它失败时如何通过“破坏的Web部件”网页从SharePoint获得堆栈转储并追溯到它的真实起源。感谢所有试过的人!