Thursday, October 1, 2009

How to automatically register CpcView Registration Key Using ASp.NET Web Forms

I came cross problem where i have to register activex control via web application. I thought putting this sample will help other users who can use my code for further registration key which are on provided on third party website. such as cartesiannic where we have to send user and password information and they post regkey on there website. So this is how I have used to register this automatically via web application

If you ever used cartesianinc cpc view controls then you can register components via website automatically

Page 1. will have in html source code: (uncomment code below)
<!--embed type="image/cpi" width="0" height="0" redirect='<%=href%>'-->

Page 1. Code behind will have:

Imports System.Web
Partial Public Class _Default
Inherits System.Web.UI.Page
Dim embed_src As String = "RegisterCPCView.aspx"

Property href() As String
Get
Return embed_src
End Get
Set(ByVal value As String)
embed_src = value
End Set
End Property 'href

End Class

In your Page 2 "RegisterCPCView" form you will write:

Imports System
Imports System.Xml
Imports System.IO
Imports System.Net

Partial Public Class RegisterCPCView
Inherits System.Web.UI.Page

Private accountID As String = "username"
Private accountPW As String = "password"
Private regKey As String = ""
Private myPageInstace As New Control
Private fs As FileStream
Private URL As String = ""
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
'reg.cgi?product=cpcview&build=33&autoreg=0&license=individual&version=6.5.1AX&arch=33333&days=333&docs=33

Dim arch As String = ""
arch = Request.QueryString("arch")
Dim cartesianURL As String = "http://www.cartesianinc.com/Prepaid/Ops/GetLicense.cgi"
URL = cartesianURL + "?accountID=" + accountID + "&" + "accountPW=" + accountPW + "&" + "machineID=" + arch

GetKey()
End If
End Sub

Property href() As String
Get
Return regKey
End Get
Set(ByVal value As String)
regKey = value
End Set
End Property 'href

Private Sub GetKey()
Dim objWebClient As New WebClient()
Dim strURL As String = URL
Dim objUTF8 As New UTF8Encoding()
Dim htrmlSource As String = objUTF8.GetString(objWebClient.DownloadData(strURL))

href = Mid(htrmlSource, 9, 16)

Response.Redirect("~/RegisterCPCViewComplete.aspx?reg=" + href)
End Sub

End Class

In your Page 3 "RegisterCPCViewComplete.aspx" you will register the reterive registration key which you have get back from : "http://www.cartesianinc.com/Prepaid/Ops/GetLicense.cgi" third party

Page 3 Html Source Code:(uncomment code below)
<!--embed type="image/cpi" width="0" height="0" regKey='<%=href%>'-->

Page 3 Code behind:
Public Partial Class RegisterCPCViewComplete
Inherits System.Web.UI.Page
Private regKey As String = ""

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not String.IsNullOrEmpty(Request.QueryString("reg")) Then
href = Request.QueryString("reg")
End If
End Sub

Property href() As String
Get
Return regKey
End Get
Set(ByVal value As String)
regKey = value
End Set
End Property 'href
End Class

Thank You.
Please don't forget to visit:

http://www.netfixllc.com
http://www.lendmyspace.com
http://www.lookfordeal.com

No comments:

Post a Comment