将ASP.net转换为经典的ASP代码 [英] Conversion of ASP.net To classic ASP code
本文介绍了将ASP.net转换为经典的ASP代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的ASP.Net代码
This is my ASP.Net code
PRN.Text = Request["PRN"].ToString();
我想将此代码转换为经典的ASP.
如果有人给我,请感谢我将上述Asp.net代码转换为Classic ASP.
问候,
Ravi
This Code i want to convert to classic ASP.
Its grateful for me if anybody give me Conversion of above Asp.net code to Classic ASP.
Regards,
Ravi
推荐答案
在经典ASP中,如果要分配请求变量值,则可以执行以下操作:
In classic asp, if you want to assign request variable value, then you can do the following:
Dim myVar
myVar = Request.form("PRN")
PRN.Text = Request.Form["PRN"].ToString();
Imports System.Security.Cryptography.X509Certificates
Imports System.Net.Security
Imports System.IO
Imports System.Net
''' <summary>
''' This Function is Used for SSL Certificate Validation
''' </summary>
''' <remarks></remarks>
Public Class SMSNICGateway
Function CertificateValidationCallBack( _
ByVal sender As Object, _
ByVal certificate As X509Certificate, _
ByVal chain As X509Chain, _
ByVal sslPolicyErrors As SslPolicyErrors _
) As Boolean
Return True
End Function
''' <summary>
'''
''' </summary>
''' <param name="receiver">Comma Seperated List of 10 digit Mobile Nos. e.g. 9568693696,9856235869,8562354859</param>
''' <param name="message">Text Message to be Sent</param>
''' <returns></returns>
''' <remarks></remarks>
Public Function Send_Message(ByVal receiver As String, ByVal message As String) As String
Dim UserName As String = "XXXXXX"
Dim Password As String = "XXXXXX"
Dim smsFrom As String = "XXXXXX"
Dim smsTo As String = receiver
Dim concat As Integer
If (Len(message) > 160) Then
concat = 1
Else
concat = 0
End If
' concat parameter is used as mentioned in the NIC SMS service document
Dim GateWayURL As String = "https://smsgw.nic.in/sendsms_nic/sendmsg.php?uname=" + UserName + "&pass=" + Password + "&send=" + smsFrom + "&dest=" + smsTo + "&msg=" + message + "&concat=" & concat & ""
' GateWayURL and Query String Parameter Names used here are Provided by NIC
'Create HTTP Web Request to be sent in background
Dim objUTFEncode As New UTF8Encoding
Dim arrRequest As Byte()
Dim objStreamReq As Stream
Dim objStreamRes As StreamReader
Dim objHttpRequest As HttpWebRequest
Dim objHttpResponse As HttpWebResponse
Dim objUri As New Uri(GateWayURL)
objHttpRequest = WebRequest.Create(objUri)
objHttpRequest.KeepAlive = False
objHttpRequest.Timeout = 40000
objHttpRequest.Method = "POST" ' You can also use GET method here
objHttpRequest.ContentType = "application/x-www-form-urlencoded"
ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf CertificateValidationCallBack) ' For SSL Certificate Validation
arrRequest = objUTFEncode.GetBytes(message)
objHttpRequest.ContentLength = arrRequest.Length
objStreamReq = objHttpRequest.GetRequestStream()
objStreamReq.Write(arrRequest, 0, arrRequest.Length)
objStreamReq.Close()
'Get HTTP Response
Try
objHttpResponse = objHttpRequest.GetResponse()
objStreamRes = New StreamReader(objHttpResponse.GetResponseStream(), Encoding.ASCII)
Dim status As String = objStreamRes.ReadToEnd()
objStreamRes.Close()
Return status 'If first two characters of status are "NH" then SMS is Sent Successfully otherwise Error Message is returned
Catch ex As WebException
Return ex.ToString
End Try
End Function
End Class
这篇关于将ASP.net转换为经典的ASP代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文