March 2008 - Posts
By Nannette Thacker
Here is an example of how to set a spam trap without using Captcha. In your web form, typically a Register or Log In page, simply place a hidden textarea field. Then on your form action page, check the value and if it contains any content, you can redirect them to another page or do anything you like. Since a real human won't see or have access to this form field, only the bots will fill in the field.
ASP.net VB Example
<asp:TextBox ID="ReasonCatch" runat="server"
Rows="3" Style="display: none;"
TextMode="MultiLine"></asp:TextBox>
<asp:Button ID="GoButton" runat="server" Text="Go"
TabIndex="5" OnClick="GoButton_Click" />
Retrieve
Protected Sub GoButton_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
Dim spamtrap As String = ""
spamtrap = Me.ReasonCatch.Text
If Not String.IsNullOrEmpty(spamtrap) Then
Response.Redirect("~/byefool.aspx", False)
Else
' further processing
End If
End Sub
ASP Classic Example
<textarea id="ReasonCatch" name="ReasonCatch"
rows="3" cols="4" style="display: none;"></textarea>
Retrieve
spamtrap = Request.Form("reasoncatch")
if cstr(spamtrap) <> "" then
Response.Redirect("/byefool.asp")
end if
In my actual code, I retrieve the IP address, and send an email to myself with the phrase they sent, along with the IP address, date and time, etc.
This helps to keep these spammers from mucking up your database with garbage records. So far I have caught and stopped a russian website spammer, a geocities spammer, and some really nasty porn links.
I found the original suggestion at the bottom of this page on A CAPTCHA Solution Built With Classic ASP, CSS And Javascript and it works great! I can't tell who the author is from looking at the site, but thanks!
May your dreams be in ASP.net!
Nannette Thacker
By Nannette Thacker
In the third installment of this tutorial, we discuss how to bind the contents of our uploaded Excel spreadsheet to our GridView. A Zip file with the complete source code, Excel Spreadsheet, and SQL Server Database is available for download.
The article series hosted on 4guysfromrolla.com continues with Importing an Excel Spreadsheet Using Typed DataSets and TableAdapters: Displaying the Uploaded Excel Spreadsheet.
Download the Application in ZIP Format
May your dreams be in ASP.NET!
Nannette Thacker
By Nannette Thacker
In the second installment of this tutorial, we discuss how to build the ASP.NET page for importing the Excel spreadsheet. We will create the page's user interface and add file upload capabilities. A Zip file with the complete source code, Excel Spreadsheet, and SQL Server Database is available for download.
The article series hosted on 4guysfromrolla.com continues with Importing an Excel Spreadsheet Using Typed DataSets and TableAdapters: Building the Importer Web Page and Uploading the Excel Spreadsheet.
Download the Application in ZIP Format
May your dreams be in ASP.NET!
Nannette Thacker
By Nannette Thacker
In web application development, three-tier architecture refers to separating the application process into three specific layers. What the user sees via a web browser is called the presentation tier and is content served from a web server. The middle tier performs the business logic processing that occurs, for example, when a user submits a form. The back end consists of the data tier which handles the database processing and access to the data. We'll take a simplistic look at each of these.
Presentation Tier
The Presentation Tier or User Interface is the portion the user sees when they open a web page in the browser. It is as simple as you reading this article all the way to searching a catalog and purchasing a product using a shopping cart. It is what is presented to the user on the client side within their web browser.
If you were to view the source code, you would only see code such as HTML, Javascript, and Cascading Style Sheets. On some sites, you may see Java Applets and Flash. Viewing source code on a web page, you would NOT see database queries or loops or calls to classes or any behind-the-scenes processing.
In ASP.net and utilizing Visual Studio or Visual Web Developer, developers can separate the user interface from the business logic and data access layer with various tools.
ASP.net allows using MasterPages to setup the site look and feel. As well, when creating a WebForm which utilizes the MasterPage, you may create it and allow the code to be placed in a separate file, known as codebehind, thus keeping your business logic in a separate layer from the look and feel.
You may also setup the site design using Themes, Skins, and Cascading Style Sheets.
Languages used in this layer are typically HTML, DHTML, CSS and javascript.
Business Logic or Application Tier
The Business Logic, Functional Process Logic, Business Rules (all pertaining to the same thing), are kept in a separate layer. In ASP.net, this is where you define your classes and source code. This can be in the App_Code folder for your classes and methods. Web languages typically used in ASP.net are VB and C#. You would not use HTML or Javascript in this layer. In this layer you typically define your classes, functions, sub procedures, properties, etc.
Data Access Tier
In ASP.net, the Data Access layer is where you define your typed datasets and tableadapters. It is where you define your queries or stored procedures. The business tier may then make use of this functionality. In your classes, rather than defining ad hoc queries, you may use a TableAdapter to access the Data Access Layer.
An Example
As an example of how this works, let's assume you are creating a web page that allows the user to enter information which you wish to then enter into a database. You first create a dataset and tableadapter that allows insert into the table, either by a query or stored procedure. This is your data access layer.
You then create a class, which retrieves the information from the form, checks for field validations and then uses the tableadapter to send the data to the database.
You create a web form, which can use a GridView control or other controls to allow the user to input the data into the web form. In the codebehind of the web form, you handle the submit button click event, and send the data from the form to your class, which sends the information to the database using the tableadapter.
Benefits
When utilized properly, using a multi-tier architecture improves performance and scalability. If a web page needs an update or redesign, all of this may be handled by altering the CSS and HTML, without affecting the business or data logic. Any of the three tiers may be replaced or upgraded individually without affecting the other tiers. For instance, if you change the database on the back end, it wouldn't affect the presentation or business logic tiers, other than changing the database connection.
This is a simple introduction to the three-tier web architecture, but I hope it has helped you understand the layers of a multi-tier architecture.
May your dreams be in ASP.net!
Nannette Thacker
Check out our new website design and let me know what you think! (Maybe, if you're going to be nice that is. ;)
http://www.shiningstar.net/ASPNet_Articles/articles.aspx
Just to be technical I guess....
The new look and feel was designed by Dylan using PhotoShop and Adobe Illustrator. I broke out the images for the web and set up the HTML, CSS, and DHTML for the master page and themes.
It's designed in ASP.NET using VB and SQL Server. It uses Master Pages and Codebehind. It uses cascading style sheets, themes and styles, custom user controls, and menu controls. It uses a custom membership provider to the SQL Server database. Anyway, that's the gist of it.
Nannette
P.S. The site has been updated since this posting. The link above takes to the original Dylan design. But now we have another design at:
http://www.shiningstar.net/
More Posts