473,626 Members | 3,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please Help!

Guys I need your help on this.

I have this one problem and I admitted I am a novice at this. This is a Code
Behind in an aspx page. You will see where I have the plus signs below in
SecureQueryStri ng2.vb where I am calling another Class called
"InvalidQuerySt ringException". My problem is where do I put this code so it
can be called from SecureQueryStri ng2.vb. I have tried to put it in the same
code behind SecureQueryStri ng2.vb and I get errors. How should I do this to
make it work and also check my .ASPX page to make sure I and referencing it
correctlly. Thanks for your help in advance.

Here is the code for InvalidQueryStr ingException:
=============== ===============
Public Class InvalidQueryStr ingException
Inherits System.Exceptio n
End Class
=============== ===============

Code Behind named: SecureQueryStri ng2.vb
=============== ===============
Imports System
Imports System.Collecti ons.Specialized
Imports System.Security .Cryptography
Imports System.Text
Imports System.Web

Namespace dma

Public Class SecureQueryStri ng
Inherits NameValueCollec tion
Private Const cryptoKey As String = "test"
Private ReadOnly IV As Byte() = New Byte(7) {240, 3, 45, 29, 0, 76,
173, 59}

Sub New()
End Sub

Sub New(ByVal encStr As String)
deserialize(Dec rypt(encStr))
End Sub

Public ReadOnly Property EncryptedString () As String
Get
Return HttpUtility.Url Encode(Encrypt( Serialize()))
End Get
End Property

Public Overrides Function ToString() As String
Return EncryptedString
End Function

Private Function Encrypt(ByVal serQS As String) As String
Dim buffer As Byte() = Encoding.ASCII. GetBytes(serQS)
Dim des As TripleDESCrypto ServiceProvider = New
TripleDESCrypto ServiceProvider
Dim md5 As MD5CryptoServic eProvider = New
MD5CryptoServic eProvider
des.Key =
md5.ComputeHash (ASCIIEncoding. ASCII.GetBytes( cryptoKey))
des.IV = IV
Return
Convert.ToBase6 4String(des.Cre ateEncryptor.Tr ansformFinalBlo ck(buffer, 0,
buffer.Length))
End Function

Private Function Decrypt(ByVal encQS As String) As String
Try
Dim buffer As Byte() = Convert.FromBas e64String(encQS )
Dim des As TripleDESCrypto ServiceProvider = New
TripleDESCrypto ServiceProvider
Dim MD5 As MD5CryptoServic eProvider = New
MD5CryptoServic eProvider
des.Key =
MD5.ComputeHash (ASCIIEncoding. ASCII.GetBytes( cryptoKey))
des.IV = IV
Return
Encoding.ASCII. GetString(des.C reateDecryptor( ).TransformFina lBlock(buffer,
0, buffer.Length() ))
+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ ++++++++++++++
Catch ex As CryptographicEx ception
Throw New InvalidQueryStr ingException
Catch ex As FormatException
Throw New InvalidQueryStr ingException
+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ ++++++++++++++
End Try
End Function

Private Sub Deserialize(ByV al decQS As String)
Dim nameValuePairs As String() = decQS.Split("&" )
Dim i As Integer
For i = 0 To nameValuePairs. Length - 1
Dim nameValue As String() = nameValuePairs( i).Split("=")
If nameValue.Lengt h = 2 Then
Me.Add(nameValu e(0), nameValue(1))
End If
Next
End Sub

Private Function Serialize() As String
Dim sb As StringBuilder = New StringBuilder
Dim key As String
For Each key In Me.AllKeys
sb.Append(key)
sb.Append("=")
sb.Append(Me(ke y))
sb.Append("&")
Next key
Return sb.ToString
End Function

End Class
End Namespace

Here is my .ASPX page code:
=============== =====

<%@ Page language="VB" src="SecureQuer yString2.vb" AutoEventWireup ="false"
Inherits="Secur eQueryString" %>
<%@ Import Namespace="dma" %>

<script language="VB" runat="server">
'Sending page
Dim qs
qs = new SecureQueryStri ng()
qs("Name") = "Test"
qs("Phone") = "704-822-8999"
Response.Redire ct("Data2.aspx? x=" + qs.ToString())
</script >

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitl ed Document</title>
</head>
<body>
</body>
</html>

--
Thanks,


Mar 29 '06 #1
6 2530
you shouldn't have a problem with this code -- as long as you're
properly referencing whatever namespace your
"InvalidQuerySt ringException" class is defined within. if you want,
you can put it in the same codebehind file, within your "dma"
namespace, and this code should work fine... otherwise, if it's in a
different namespace, you'd have to reference it accordingly within your
codebehind. e.g.:

=============== ========
SecureQueryStri ng2.vb
=============== ========

Namespace dma
Public Class InvalidQueryStr ingException Inherits System.Exceptio n
End Class

Public Class SecureQueryStri ng
...
Throw New InvalidQueryStr ingException
...
End Class
End Namespace
--- OR ---
=============== ========
Functions.vb
=============== ========

Namespace dmaFunctions
Public Class InvalidQueryStr ingException Inherits System.Exceptio n
End Class
End Namespace

=============== ========
SecureQueryStri ng2.vb
=============== ========

Imports dmaFunctions

Namespace dma
Public Class SecureQueryStri ng
...
Throw New InvalidQueryStr ingException
// OR "Throw New dmaFunctions.In validQueryStrin gException",
// if you don't include "Imports dmaFunctions"
...
End Class
End Namespace
HTH,
Luke

Mar 29 '06 #2
Luke, I want to say thank you for helping me with this, I really appricaite
it. I tried the first option and then run the DATA.ASPX file below and I got
this error. It doesn't make sense. SecureQueryStri ng2.vb is in the same
folder with DATA.ASPX.
Server Error in '/' Application.
--------------------------------------------------------------------------------

Parser Error
Description: An error occurred during the parsing of a resource required to
service this request. Please review the following specific parse error
details and modify your source file appropriately.

Parser Error Message: The base type 'SecureQueryStr ing' does not exist in
the source file 'SecureQueryStr ing2.vb'.

Source Error:
Line 1: <%@ Page language="VB" src="SecureQuer yString2.vb"
AutoEventWireup ="false" Inherits="Secur eQueryString" %>
Line 2: <%@ Import Namespace="dma" %>
Line 3:
Source File: d:\inetpub\wwwr oot\websites\sp ecialk\test\Dat a.aspx Line: 1

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.432 2.2032; ASP.NET
Version:1.1.432 2.2032
+++++++++++++++ ++++++++++++
Here is the code for DATA.ASPX:+
+++++++++++++++ ++++++++++++

<%@ Page language="VB" src="SecureQuer yString2.vb" AutoEventWireup ="false"
Inherits="Secur eQueryString" %>
<%@ Import Namespace="dma" %>

<script language="VB" runat="server">
'Sending page
Dim qs
qs = new SecureQueryStri ng()
qs("Name") = "Test"
qs("Phone") = "777-888-9999"
Response.Redire ct("Data2.aspx? x=" + qs.ToString())
</script >

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitl ed Document</title>
</head>
<body>
</body>
</html>

Any idea why this is not working?

Thanks.


"slagomite" <sl*******@gmai l.com> wrote in message
news:11******** **************@ v46g2000cwv.goo glegroups.com.. .
you shouldn't have a problem with this code -- as long as you're
properly referencing whatever namespace your
"InvalidQuerySt ringException" class is defined within. if you want,
you can put it in the same codebehind file, within your "dma"
namespace, and this code should work fine... otherwise, if it's in a
different namespace, you'd have to reference it accordingly within your
codebehind. e.g.:

=============== ========
SecureQueryStri ng2.vb
=============== ========

Namespace dma
Public Class InvalidQueryStr ingException Inherits System.Exceptio n
End Class

Public Class SecureQueryStri ng
...
Throw New InvalidQueryStr ingException
...
End Class
End Namespace
--- OR ---
=============== ========
Functions.vb
=============== ========

Namespace dmaFunctions
Public Class InvalidQueryStr ingException Inherits System.Exceptio n
End Class
End Namespace

=============== ========
SecureQueryStri ng2.vb
=============== ========

Imports dmaFunctions

Namespace dma
Public Class SecureQueryStri ng
...
Throw New InvalidQueryStr ingException
// OR "Throw New dmaFunctions.In validQueryStrin gException",
// if you don't include "Imports dmaFunctions"
...
End Class
End Namespace
HTH,
Luke

Mar 30 '06 #3
Hrm, not sure why the error says it doesn't exist -- but the true
problem probably lies in the fact that your ASPX page is inheriting
from a class that does not inherit from System.Web.UI.P age (I didn't
notice this problem before). In your ASPX page, you want to inherit a
page class, something like:

<%@ Page Language="VB" src="Data.aspx. cs" AutoEventWireup ="False"
Inherits="Data" %>

and in your the Data.aspx.cs codebehind file:

Public Class Data Inherits System.Web.UI.P age
...
End Class

ASPX pages need to inherit from a class that inherits from
System.Web.UI.P age. In other words, your ASPX page shouldn't be
*extending* your SecureQueryStri ng() class -- it should just be *using*
it.

HTH
Luke

Mar 30 '06 #4
I took out the "Inherits NameValueCollec tion" and replaced it with "Inherits
System.Web.UI.P age" and tried to execute it. I got a server error. But when
I change it back I still get the previous error.

Server Error in '/' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30456: 'Add' is not a member of
'System.Web.UI. Page'.

Source Error:
Line 86: Dim nameValue As String() = nameValuePairs( i).Split("=")
Line 87: If nameValue.Lengt h = 2 Then
Line 88: MyBase.Add(name Value(0), nameValue(1))
Line 89: End If
Line 90:
System.Math.Min (System.Threadi ng.Interlocked. Increment(i),i-1)

Source File: d:\inetpub\wwwr oot\websites\sp ecialk\test\Sec ureQueryString. vb
Line: 88
"slagomite" <sl*******@gmai l.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .
Hrm, not sure why the error says it doesn't exist -- but the true
problem probably lies in the fact that your ASPX page is inheriting
from a class that does not inherit from System.Web.UI.P age (I didn't
notice this problem before). In your ASPX page, you want to inherit a
page class, something like:

<%@ Page Language="VB" src="Data.aspx. cs" AutoEventWireup ="False"
Inherits="Data" %>

and in your the Data.aspx.cs codebehind file:

Public Class Data Inherits System.Web.UI.P age
...
End Class

ASPX pages need to inherit from a class that inherits from
System.Web.UI.P age. In other words, your ASPX page shouldn't be
*extending* your SecureQueryStri ng() class -- it should just be *using*
it.

HTH
Luke

Mar 30 '06 #5
No. Don't change the inheritance of the SecureQueryStri ng class --
change the inheritance of your page class, in the @Page directive --
the value of the "Inherits" attribute should match the name of your
codebehind class.

Please take another look at the code I wrote out in my last post.

Luke

Apr 4 '06 #6
Also, please note that your ASPX page should *not* use the
SecureQueryStri ng class as its codebehind -- SecureQueryStri ng should
just be a stand-alone class; you should have *another* class as your
codebehind (the name of the file which contains it should be the the
name of your ASPX page, with ".vb" appended -- e.g., if your ASPX page
is called "Data.aspx" , your codebehind file should be called
"Data.aspx. vb", and the name of the codebehind class in that file
should be "Data").

Visual Studio should have created such a codebehind file for you -- to
view it, right-click somewhere in your HTML view of the ASPX page, and
click "View Code".

HTH,
Luke

Apr 4 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1693
by: Kurt Watson | last post by:
I’m having a different kind of problem with Hotmail when I sign in it says, "Web Browser Software Limitations Your Current Software Will Limit Your Ability to Use Hotmail You are using a web browser that Hotmail does not support. If you continue to use your current browser software we cannot guarantee that Hotmail will work correctly for you". Please help, this is very annoying. I have been searching for help on
7
3593
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title> </head> <style type="text/css">
7
3276
by: tyler_durden | last post by:
thanks a lot for all your help..I'm really appreciated... with all the help I've been getting in forums I've been able to continue my program and it's almost done, but I'm having a big problem that I believe if it's solved, the remaining stuff is easy... my full program until now is here: http://www.geocities.com/tom4_h4wk/progmail.zip the problem is the segmentation fault when main trys to run leficheiro.c.... the *.c2 files are the...
23
3259
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application to create certain textboxes, labels, and combo boxes? Any ideas would be appreciated. Thanks
13
4316
by: Joner | last post by:
Hello, I'm having trouble with a little programme of mine where I connect to an access database. It seems to connect fine, and disconnect fine, but then after it won't reconnect, I get the error "operation is not allowed when object is open" so I take out the line of code: BookDetails.Connection1.Open and it comes up with the error "operation is not allowed when object
1
9623
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
1
54492
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and we instruct our experts to ignore any such PMs completely Be sure to give the version of Access that you are working with and the Platform and OS if applicable.
0
3043
by: 2Barter.net | last post by:
newsmail@reuters.uk.ed10.net Fwd: Money for New Orleans, AL & GA Inbox Reply Reply to all Forward Print Add 2Barter.net to Contacts list Delete this message Report phishing Show original
6
3310
by: jenipriya | last post by:
Hi all... its very urgent.. please........i m a beginner in oracle.... Anyone please help me wit dese codes i hv tried... and correct the errors... The table structures i hav Employee (EmpID, EmpName,DeptID,DateOfJoin, Sal, Addr) Finance (EmpID, Sal) Club (Clubname, EmpID, Fee, DateOfJoin) Leave (EmpID, Date) Department (DeptID, DeptName, NoOfEmployees)...
5
2301
by: tabani | last post by:
I wrote the program and its not giving me correct answer can any one help me with that please and specify my mistake please it will be highly appreciable... The error arrives from option 'a' it asks for user name, check in the system but does not return the correct answer please help me with it. or if you have better way of doing it would you please mind to tell me.. thanks.. #!/usr/bin/perl -w #use Getopt::Std;
0
8265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.