Showing posts with label working. Show all posts
Showing posts with label working. Show all posts

Wednesday, March 28, 2012

TripleDES with Hexadecimal Key

I am working with a web service which requires enryption of some XML
fields. It will be symmetric encryption - TripleDES.
The vendor has given me the Key that we will share. With the exception
that there are 48 characters in the actual Key that he gave me, here
is an example of what he gave me: 0E329232EA6D0D73 (The vendor has
told me to use all zeros for the IV.)
How can I use this with the .Key property of
TripleDESCryptoServicerProvider? I realize that what he is giving me
is hexadecimal, but how do I convert it a .Key that I can use with
the .NET framework. The only way that I can see to set the .Key
property is: Dim objDES.Key as Byte() = {48, 3, 17, 131, 202, ....and
so on}
How do I either convert the .Key that the vendor has given me to the
VB.NET language above - or is there another to set the .Key property
that I am overlooking?
Any help anyone could give would be hugely appreciated - thanks!It 0E329232EA6D0D73 is hexadecimal notation of 14, 50, ... in decimal
where did 48, 3, 17, 131, 202, came from?
Use calc.exe to convert it to decimal and write correct values
Dim objDES.Key as Byte() = {14, 50, }
Or you can use
Int32.Parse("0E", NumberStyles.HexNumber )
Int32.Parse("32", NumberStyles.HexNumber )
...
George
"Celia" <c.oblinger@.gmail.com> wrote in message
news:0dcd82f2-3eaa-480d-81cf-749e6158fbd1@.s8g2000prg.googlegroups.com...
>I am working with a web service which requires enryption of some XML
> fields. It will be symmetric encryption - TripleDES.
> The vendor has given me the Key that we will share. With the exception
> that there are 48 characters in the actual Key that he gave me, here
> is an example of what he gave me: 0E329232EA6D0D73 (The vendor has
> told me to use all zeros for the IV.)
> How can I use this with the .Key property of
> TripleDESCryptoServicerProvider? I realize that what he is giving me
> is hexadecimal, but how do I convert it a .Key that I can use with
> the .NET framework. The only way that I can see to set the .Key
> property is: Dim objDES.Key as Byte() = {48, 3, 17, 131, 202, ....and
> so on}
> How do I either convert the .Key that the vendor has given me to the
> VB.NET language above - or is there another to set the .Key property
> that I am overlooking?
> Any help anyone could give would be hugely appreciated - thanks!

Monday, March 26, 2012

Trouble getting an "Update Quantities" Button Working

Hello,

I am trying to create a click handler on an update quantities button which updates the quantities with the textbox. I am using a datalist and have addressed the "ProductID" as the DataKeyField. Can someone please help me code this?

This is the code
--------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Dim productID As String = Request.Params("AddToCart" )
If Not productID Is Nothing Then
Dim cart As New ShoppingCart()
cart.AddProduct(productID)
End If
BindShoppingCart()
checkoutCodeLabel.Text = "Checkout Code: "
End If
End Sub

Private Sub BindShoppingCart()
Dim cart As New ShoppingCart()
list.DataSource = cart.GetProducts
list.DataKeyField = "ProductID"
list.DataBind()

If cart.GetTotalAmount = 0 Then
placeOrderButton.Enabled = False
Else
placeOrderButton.Enabled = True
End If

TotalAmount.Text = "Total amount:"

totalAmountLabel.Text = String.Format("{0:c}", cart.GetTotalAmount())
End Sub

Private Sub btnUpdateQuantity_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateQuantity.Click
(WHAT DO I PUT HERE??????????)
End Sub

Thanks in advance!Where you can get the total after you click the update button and page post back? looks like all the code in page_load will not run for they are in "If Not Page.IsPostBack ".

Thursday, March 22, 2012

Trouble with new server

I have switched to a new server and all of a sudden all my sites have stopped working.

Trying to simply the sites to narrow down the error I have found that a blank page with a code behind file (also empty) will not run. The page is helpfully only giving the runtime error message saying to put customerrors = "Off" in web.config but if I put any form of web.config file up I get the same error even with a page that runs fine without a default config file.


If I put my code in the file rather than code behind then the code operates (assuming there is no web.config file etc)


Any ideas anyone?

have you verified that the new webserver is set to asp.net 2.0? also, you should turn customerrors to off so you can see the actual error. that would be helpful (or if you can remote in, you will see the error if you run localhost.)


I tried turning custom errors off and it made no difference.

I found out that contrary to them saying it is 2.0 the machine actually only has 1.1 installed on it.

Trouble with Office XP PIAs and VS.NET2005 Beta1

Hi...

Trying to use the Office XP PIA's, and it ain't working.

I have installed and registered them into the GAC per the instructions, and I've checked the Registry - sure enough, they're all registered as thePrimaryInterface Assemblies. However, when I try to add a Reference to the Word Object Library, the only one that shows up in the COM list is v. 9.0, not the 10.0... version from the XP PIA's.

When I select the 9.0 version, VS adds a reference to the Word dll but the CopyLocal property is set to "true"... I don't think it's supposed to be if it's using the Primary assembly.

I need to get this dumb program to open Word and manipulate literally hundreds of .doc files... any help would be greatly appreciated.

Thanks.

Test reply by moderator SomeNewKid

Trouble with Radiobuttons

Hi,

I am working on this project of creating webforms and this one particular page has a bunch of radiobuttons in it. Once the user clicks one of the radiobuttons and then clicks on submit, the user is redirected to a different webform. In the event handler for the submit button, I check to see if that one particular radiobutton has been clicked or not ,kinda like this below:

privatevoid InitializeComponent()

{

this.submit_button.Click +=new System.EventHandler(this.submit_button_Click);

}

privatevoid submit_button_Click(object sender, System.EventArgs e)

{

if (radiobutton1.Checked ==true)

{

Response.Redirect("page1.aspx");

}

The problem is when I check radiobutton1 and then click submit, nothing happens and I stay on the same page. I ran the debugger and it didn't even step through the code. Can anyone help me out here?

Try this - uses both types of radio button/list

<%@.PageLanguage="C#" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<scriptrunat="server">

protectedvoid RadioButton3_CheckedChanged(object sender,EventArgs e)

{

Response.Redirect("Default.aspx?Fruit=" + Server.HtmlEncode(((RadioButton)sender).Text));

}

protectedvoid RadioButtonList1_SelectedIndexChanged(object sender,EventArgs e)

{

Response.Redirect("Default.aspx?Fruit=" + Server.HtmlEncode(RadioButtonList1.SelectedValue));

}

</script>

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Untitled Page</title>

</head>

<body>

<formid="form1"runat="server">

<div>

<asp:RadioButtonID="RadioButton1"runat="server"GroupName="RB1"Text="Apples"OnCheckedChanged="RadioButton3_CheckedChanged"/>

<asp:RadioButtonID="RadioButton2"runat="server"GroupName="RB1"Text="Oranges"

OnCheckedChanged="RadioButton3_CheckedChanged"/>

<asp:RadioButtonID="RadioButton3"runat="server"GroupName="RB1"Text="Gone Bananas"

OnCheckedChanged="RadioButton3_CheckedChanged"/>

</div>

<div>

<asp:RadioButtonListID="RadioButtonList1"runat="server"OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">

<asp:ListItem>Pears</asp:ListItem>

<asp:ListItem>Cherries</asp:ListItem>

<asp:ListItem>WinkleBerry</asp:ListItem>

</asp:RadioButtonList>

</div>

<asp:LinkButtonID="LinkButton1"runat="server">Submit</asp:LinkButton>

</form>

</body>

</html>


Thanks for the response...I am working with .aspx files...So instead of embedding scripts like you suggested, I have to write backend code in the .aspx.cs files..Its just that after I click on the submit button it should hit that part of the code where I have the event handler in case the submit button is clicked. I still can't figure out why its not doing that...I am working on a visual studio 2003 platform

Tuesday, March 13, 2012

Troubles working with dates

Hello people im new on this, but im going to try to explain my self as well as possible.

Im working with Vb.net code.

I'm having this trouble, i have a datagrid in wich i add a colum wich calculates the time that a "ticket" has been in the system. The calculation function is called when the datagrid is been loaded.

Im having troubles when im trying to use the system in another machine that doesnt have Vstudio.

the page give me this error, and i try to change the var type to string and it doesnt work either.

CAST FROM STRING "31/03/2006" TO TYPE "DATE" IS NOT VALID

this is the code im using

Private Sub calcula_duracion(ByVal estado_sol As String)
Dim i As Integer
Dim ahora, entonces As DateTime
Dim tempdate1, tempdate2, tempdate3 As DateTime
Dim dias, horas, minutos, segundos, result As String

For i = 0 To dsconsulta.Tables(0).Rows.Count - 1
If estado_sol = "Pendiente" Or estado_sol = "Eliminada" Then
ahora = Now
ElseIf estado_sol = "Aceptada" Then
ahora = dsconsulta.Tables(0).Rows(i).Item("fec_aceptacion")
ElseIf estado_sol = "Rechazada" Or estado_sol = "Solucionada" Then
ahora = dsconsulta.Tables(0).Rows(i).Item("fec_solucion")
ElseIf estado_sol = "Aceptada" Then
ahora = dsconsulta.Tables(0).Rows(i).Item("fec_aceptacion")
End If

lbltot.Text = dsconsulta.Tables(0).Rows.Count
entonces = dsconsulta.Tables(0).Rows(i).Item("fec_creacion")
tempdate1 = Format(entonces, "dd/MM/yyyy")
tempdate3 = Format(ahora, "dd/MM/yyyy")
tempdate2 = Format(ahora, "HH:mm")
If tempdate2 < CDate("8:00AM") Then
ahora = tempdate3 + " " + CDate("8:00AM")
ElseIf tempdate2 > CDate("6:00PM") Then
ahora = tempdate3 + " " + CDate("8:00AM")
ahora = ahora.AddDays(1)
End If

If DateDiff(DateInterval.Day, tempdate1, tempdate3) > 0 Then
dias = DateDiff(DateInterval.Day, tempdate1, tempdate3)
ahora = ahora.AddDays(-dias)
If DateDiff(DateInterval.Hour, entonces, ahora) < 0 Then
horas = DateDiff(DateInterval.Hour, ahora, entonces)
entonces = entonces.AddHours(-horas)
Else
horas = DateDiff(DateInterval.Hour, entonces, ahora)
ahora = ahora.AddHours(-horas)
End If
minutos = DateDiff(DateInterval.Minute, entonces, ahora)
ahora = ahora.AddMinutes(-minutos)
segundos = DateDiff(DateInterval.Second, entonces, ahora)
result = dias & "d " & horas & ":" & minutos & ":" & segundos
ElseIf DateDiff(DateInterval.Hour, entonces, ahora) > 0 Then
dias = "0"
horas = DateDiff(DateInterval.Hour, entonces, ahora)
ahora = ahora.AddHours(-horas)
minutos = DateDiff(DateInterval.Minute, entonces, ahora)
ahora = ahora.AddMinutes(-minutos)
segundos = DateDiff(DateInterval.Second, entonces, ahora)
result = dias & "d " & horas & ":" & minutos & ":" & segundos
ElseIf DateDiff(DateInterval.Minute, entonces, ahora) > 0 Then
dias = "0"
horas = "00"
minutos = DateDiff(DateInterval.Minute, entonces, ahora)
ahora = ahora.AddMinutes(-minutos)
segundos = DateDiff(DateInterval.Second, entonces, ahora)
result = dias & "d " & horas & ":" & minutos & ":" & segundos
ElseIf DateDiff(DateInterval.Second, entonces, ahora) > 0 Then
dias = "0"
horas = "00"
minutos = "00"
segundos = DateDiff(DateInterval.Second, entonces, ahora)
result = dias & "d " & horas & ":" & minutos & ":" & segundos
Else
result = "0d 00:00:00"
End If
dsconsulta.Tables(0).Rows(i).Item("Duracion") = result
Next
End Sub

tnx for ur time and help

I see that you are using a DD/MM/YYYY format for your date. Is it possible that the Regional settings of the new machine have a different date format?

i've check that out and in the deploy machine it works fine because i have there visual studio and the sql server, but when i move the application to a network where the server is in a different pc that the one who has the IIS it doesnt work, and the IIS pc has the same regional settings that the deploy machine??

tnx

Troubleshooting asp.net on XP Pro

I'm working out of some asp.net books. The examples aren't working on my XP Pro system.
I know it's not my code because the files will work if I move them to my company's web server (Shhh, don't tell).

I set up IIS and made a virtual directory that points to a partition where I'm putting the files.
I have the .NET Framework 1.1 and ran a windows update today.

Here is an example of a problem. This For...Next statement is supposed to write a sentence 7 times in different sizes. If I load the page in my browser it displays:
> Hello and Welcome!

Here is my code:


<%@dotnet.itags.org.Page Language="VB" Debug="True" %>
<html>
<head>
<title>Hello and Welcome Page</title>
</head>
<body>
<center>
<% Dim TextSize As Integer %>
<% For TextSize = 1 To 7 %>
<font size = <%=TextSize%>>
Hello and Welcome!<br>
</font>
<% Next %>
</center>
</body>
</html
1. run aspnet_regiis.exe
2. make sure you're requesting the page via HTTP and not just from the filesystem.
When I try to run Aspnet_regiis.exe I get an error message:
The application Failed to initialize properly. (0xc0000142)

Wonder if this is my problem?
Oh, I see I have to run that command from a Visual Studio command prompt. I will try that.
aspnet_regiis.exe -i fixed the problem!
Did you tried with -i ?

Troubleshooting IIS "Hang" / Postback Not Working

I have recently added some code to a web application and now I find it
hanging after I do about 2 or 3 postbacks within the application. It hangs
after
doing different things (I cannot find anything in common) and when I run in
Debug mode, it doesn't even appear to be within my code when it hangs (I put
breakpoints all over the place and it doesn't stop at any of them during the
hang).
It hangs after I click a button on the page... but it never reaches the
Page_Load event of the page it is posting back to.. it is like the PostBack
isn't working.
How do I figure out what is going on? What really confuses me is the fact
that the code works the first time but not the second time I run it.. even
with the exact same input data...
It does seem to be related to uploading images... so I went through my code
and made sure I was disposing of all of the image objects in Finally
statements.
Any thoughts on how I can find the problem?
I have ANTS profiler by Red Gate software and I tried doing a memory profile
but it didn't seem to get me anywhere (either that or I wasn't doing it
right).
It is not causing IIS to crash... just to "spin" for a long time. This is
on my development Win XP Pro machine.
After quite some time, I get the following errors when I debug... but I
think they are more a symptom of the non-response to the application as
opposed to the cause of my problem.
--
A first chance exception of type 'System.Net.Sockets.SocketException'
occurred in system.dll
Additional information: An existing connection was forcibly closed by the
remote host
A first chance exception of type 'System.IO.IOException' occurred in
system.dll
Additional information: Unable to read data from the transport connection.
LoriHi Lori ,
Welcome to ASP.NET newsgroup.
From your description, one of your asp.net always run into hanging after
you do some modification recently. I'm not quite sure what's your orginally
code logic and what's your modification on them. However, have you been
able to isolate the problem to a certain or some certain individule pages?
Also, based on your error message, I think you're doing some network
transfering task , using Socket or httpwebrequest? Generally, if your
server's CPU utilization is not high and application hangs, it's likely
that there are some thread deadlock in your app or there are some longrun
task in your page's exectution steps which block the server's workthreads.
Would provide some further description on your code logic?
In addition, I suggest you turn on the ASP.NET's trace and use Trace.Write
or Warn to output some trace info in the different stage of those page's
execution lifecycle. For example, before page_load and after Page_Load or
before a method call and after a method call. Then, we can use the
application's trace.axd to view which stage consumes most of the times.
If there are any further findings, please feel free to post here also. Good
Luck!
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Troubleshooting IIS "Hang" / Postback Not Working

I have recently added some code to a web application and now I find it
hanging after I do about 2 or 3 postbacks within the application. It hangs
after
doing different things (I cannot find anything in common) and when I run in
Debug mode, it doesn't even appear to be within my code when it hangs (I put
breakpoints all over the place and it doesn't stop at any of them during the
hang).

It hangs after I click a button on the page... but it never reaches the
Page_Load event of the page it is posting back to.. it is like the PostBack
isn't working.

How do I figure out what is going on? What really confuses me is the fact
that the code works the first time but not the second time I run it.. even
with the exact same input data...

It does seem to be related to uploading images... so I went through my code
and made sure I was disposing of all of the image objects in Finally
statements.

Any thoughts on how I can find the problem?

I have ANTS profiler by Red Gate software and I tried doing a memory profile
but it didn't seem to get me anywhere (either that or I wasn't doing it
right).

It is not causing IIS to crash... just to "spin" for a long time. This is
on my development Win XP Pro machine.

After quite some time, I get the following errors when I debug... but I
think they are more a symptom of the non-response to the application as
opposed to the cause of my problem.
-----------
A first chance exception of type 'System.Net.Sockets.SocketException'
occurred in system.dll

Additional information: An existing connection was forcibly closed by the
remote host

A first chance exception of type 'System.IO.IOException' occurred in
system.dll

Additional information: Unable to read data from the transport connection.

LoriHi Lori ,

Welcome to ASP.NET newsgroup.
From your description, one of your asp.net always run into hanging after
you do some modification recently. I'm not quite sure what's your orginally
code logic and what's your modification on them. However, have you been
able to isolate the problem to a certain or some certain individule pages?

Also, based on your error message, I think you're doing some network
transfering task , using Socket or httpwebrequest? Generally, if your
server's CPU utilization is not high and application hangs, it's likely
that there are some thread deadlock in your app or there are some longrun
task in your page's exectution steps which block the server's workthreads.
Would provide some further description on your code logic?

In addition, I suggest you turn on the ASP.NET's trace and use Trace.Write
or Warn to output some trace info in the different stage of those page's
execution lifecycle. For example, before page_load and after Page_Load or
before a method call and after a method call. Then, we can use the
application's trace.axd to view which stage consumes most of the times.

If there are any further findings, please feel free to post here also. Good
Luck!

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)