我是asp.net的新手。您可以在C#.net代码后发布等效的vb.net代码。 感谢
public string getSecureCookie(HttpRequest Request)
{
HttpCookie secureCookie = Request.Cookies["Test"];
if(secureCookie!=null)
{
return secureCookie.ToString();
}
else
{
return "";
}
}
答案 0 :(得分:5)
运行http://www.carlosag.net/Tools/CodeTranslator/
处提供的代码转换器Public Function getSecureCookie(ByVal Request As HttpRequest) As String
Dim secureCookie As HttpCookie = Request.Cookies("Test")
If (Not (secureCookie) Is Nothing) Then
Return secureCookie.ToString
Else
Return ""
End If
End Function
但是可能想要使用If secureCookie IsNot Nothing
。但翻译确实有效。
答案 1 :(得分:2)
试试这个
Public Function getSecureCookie(ByVal request as HttpRequest) As String
Dim cookie = request.Cookies("Test")
if cookie IsNot Nothing Then
return cookie.ToString()
Else
return ""
End If
End Function