Re: Desperately need help to setup with asp net !!



Hi Ken

actually there is a simple hello world example which *seems* to be in
right direction. The rest of the documentation is quite concise and it
seems there is a long struggle to do.

I am not clear if the Process Request is routed by IIS to the
IHttpHandler (which I might enclose in my server application) or the
talk is directly between the Browser and the IHttpHandler (?)

I see not many people out there are using this stuff, but, to me, it
seems quite useful to be able to talk to an application through a
browser. If someone has some code or pointers to show how to use these
handlers it would be great.

If there other suggestions I will be listening here! Thank you

-pam


example from documentation:
----------------------------------------------------------
Imports System.Web

Public Class HelloWorldHandler
Implements IHttpHandler

Public Sub ProcessRequest(ByVal context As System.Web.HttpContext)
Implements System.Web.IHttpHandler.ProcessRequest
Dim request As HttpRequest = context.Request
Dim response As HttpResponse = context.Response
' A file named ending in .MyHello need not exist. This handler
' executes whenever a file ending in .MyHello is requested.
response.Write("<html>")
response.Write("<body>")
response.Write("<h1> Hello from Synchronous custom handler.
</h1>")
response.Write("</body>")
response.Write("</html>")
End Sub

Public ReadOnly Property IsReusable() As Boolean Implements
System.Web.IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class


Ken Cox [Microsoft MVP] ha scritto:

Hi Pam,

It sounds like you want to create your own custom HttpHandler. It can get
the posted query from System.Web.HttpContext and pass that along to get the
data. Once you've built the HTML code, you ship it back out with
HttpResponse.

If you do a search on IHttpHandler and HttpContext you'll get more info.
Here's a starter that generates a 'Hello World' HTML page.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconaspnetrequestprocessing.asp

Can't help more than that because I haven't used that capability. It seems
to me there must be easier ways such as user controls or Web parts to do
what you need.

Ken
Microsoft MVP [ASP.NET]


<pamelafluente@xxxxxxxxx> wrote in message
news:1151268220.863538.69320@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thank you Ken. This piece of the puzze I already have.

The problem is I want to send the request to a VB.NET program which is
running on the server because it must do some complicate processing
*before* doing the query and *after* doing the query. The response page
is not simply to fill a grid but the result of some processing that
must be done by the Vb.net application on the server. The VB.net
application also prepare a complex response page (with a lot of more
stuff, charts, pictures, photos, diagrams, etc) which I would like to
return to the browser.

What I have hard time to implement is passing data from the browser to
the VB.net application on the server, and, then, passing back the page
generated by the VB.net program back to the Browser. Just as I have
indicated in my schema. If you bypass the VB application you are not
answering to my original question. It's crucial the dialogue with the
server application.

Thanks for any help.

-Pam

Ken Cox [Microsoft MVP] ha scritto:

Hi Pam,

This sounds like a fairly simple ASP.NET page. Not sure why your spec
includes a "vb net application on a server pc" because the ASP.NET page
can
do it all... that's what it was designed for.

Anyway, let us know if the ASP.NET 2.0 code below helps?

Ken
Microsoft MVP [ASP.NET]


<%@ page language="VB" %>

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

<script runat="server">

Protected Sub btnSubmit_Click _
(ByVal sender As Object, ByVal e As System.EventArgs)
If txtQuery.Text <> "" Then
' Quick sample code to submit a SQL string
' and view the results in ASP.NET Gridview
' Ken Cox [MVP] - June 25/06
Dim strConnection As String
strConnection = "Data Source=.\SQLEXPRESS;" & _
"Initial Catalog=Northwind;Integrated Security=True"
Dim con As New Data.SqlClient.SqlConnection(strConnection)
' The following is probably not sufficient to protect you
' from a SQL injection attack but it's better than nothing
Dim cmdtext As String = SafeSqlLiteral(txtQuery.Text)
Dim cmd As New Data.SqlClient.SqlCommand(cmdtext, con)
Dim ds As New Data.DataSet
Dim da As New Data.SqlClient.SqlDataAdapter _
(cmdtext, strConnection)
da.Fill(ds)
GridView1.DataSource = ds
GridView1.DataBind()
End If
End Sub

Private Function SafeSqlLiteral(ByVal inputSQL As String) As String
Return inputSQL.Replace("'", "''")
End Function

</script>

<html xmlns="http://www.w3.org/1999/xhtml";>
<head runat="server">
<title>Textbox SQL query</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:textbox id="txtQuery" runat="server" width="470px"
text="SELECT companyname from customers"></asp:textbox><br />
<br />
<br />
<asp:button id="btnSubmit" runat="server"
onclick="btnSubmit_Click" text="Submit query" /><br />
<br />
<br />
<asp:gridview id="GridView1" runat="server">
</asp:gridview>
&nbsp;</div>
</form>
</body>
</html>

<pamelafluente@xxxxxxxxx> wrote in message
news:1151249546.731638.175320@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am beginning aspNet, I know well win apps.
Need a simple and schematic code example to start work.

This is what I need to accomplish:

----------------------
Given button and a TextBox on a web form when one presses the button on
the web form on a client pc, the sql query which is contained in the
text box is sent to a vb net application on a server pc. The win
application sends the query to the database, collects the results,
creates a web page showing some of these result and send the page back
to the browser (for future queries).

1. client (Browser, IE) ----> WinApp on a Server pc ----> Database
2. Database --> WinApp on Server pc --> create NewAspPage --> client
pc (Browser)
----------------------

I am kind of desperate and I don't know where to start . I very
*simple* example in code would really help a lot.

Help!!

-Pam



.