Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用VB.NET保护自定义Web服务?_Javascript_Asp.net_Web Services_Security_Ws Security - Fatal编程技术网

Javascript 如何使用VB.NET保护自定义Web服务?

Javascript 如何使用VB.NET保护自定义Web服务?,javascript,asp.net,web-services,security,ws-security,Javascript,Asp.net,Web Services,Security,Ws Security,我使用Visual studio 2010在VB中构建了一个简单的web服务。现在,我想通过用户名和密码保护此web服务。如果用户名和密码匹配,用户可以使用/查看内容。我的web服务如下 Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.Web.Script.Services ' To allow this Web Service to be c

我使用Visual studio 2010在VB中构建了一个简单的web服务。现在,我想通过用户名和密码保护此web服务。如果用户名和密码匹配,用户可以使用/查看内容。我的web服务如下

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Web.Script.Services

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Convert
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function HelloWorld() As String
        Return "Hello World"
    End Function

    <System.Web.Services.WebMethod()> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Function FahrenheitToCelsius(ByVal Fahrenheit As Double) _
           As Double
        Return ((Fahrenheit - 32) * 5) / 9
    End Function

    <System.Web.Services.WebMethod()> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Function CelsiusToFahrenheit(ByVal Celsius As Double) _
            As Double
        Return ((Celsius * 9) / 5) + 32
    End Function
End Class 
导入系统.Web
导入System.Web.Services
导入System.Web.Services.Protocols
导入System.Web.Script.Services
'要允许使用ASP.NET AJAX从脚本调用此Web服务,请取消注释以下行。
_
_
_
_
公共类转换
继承System.Web.Services.WebService
_
作为字符串的公共函数HelloWorld()
返回“你好,世界”
端函数
_
_
公共函数华氏度摄氏度(ByVal华氏度为双倍)_
加倍
返回((华氏-32)*5)/9
端函数
_
_
公共函数CelsiusToFahrenheit(摄氏倍率)_
加倍
返回((摄氏度*9)/5)+32
端函数
末级

我使用JavaScript和Dojo来调用它。有人能告诉我如何保护它。

这说明了一种合理的方法:


简而言之,您将发送用户名、散列密码、客户端时间戳和函数参数,以及所有这些参数的散列加上请求URL和私钥。服务器重新创建哈希以验证没有任何更改,检查时间戳是否在可接受的范围内,并执行该函数。

ASMX是一种遗留技术,不应用于新的开发。WCF应用于web服务客户端和服务器的所有新开发。一个提示:微软已经在MSDN上退出了。