ASP.NET
  Home arrow ASP.NET arrow Page 3 - Database Storage with the ASP.NET Web Matr...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Database Storage with the ASP.NET Web Matrix: Unsubscribe Page
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2005-09-28

    Table of Contents:
  • Database Storage with the ASP.NET Web Matrix: Unsubscribe Page
  • Setting up the Page
  • Calling the Function
  • Setting up a Web Directory Structure

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Database Storage with the ASP.NET Web Matrix: Unsubscribe Page - Calling the Function


    (Page 3 of 4 )

    Switch back to the Design view and double-click the submit button.  The following If statement will do everything we need when placed in between the Sub and End Sub lines of code:

    If removeUser(txtUsername.Text) <> 0 Then
            lblSuccess.Text = "You have been removed"
    Else
            lblUsernameError.Text = "* Your username does not appear
    to exist"
    End If

    This will call the function and output a success message when data is removed, or an error message advising that the Username was not found in the database.  Use the play button to test the page and have a go at removing people from the database table.

    So that is the unsubscribe page itself created, but at the moment (if this were a live page instead of a development page) anyone could access the page and run data operations without even entering a password.  To rectify this, you can create a special XML file to tell the web server who is allowed to view the unsubscribe page.  The file that can do this is of course the web.config file.  The Web Matrix has a template for a web.config file in the Security section of the page templates, so click the new file button and create one.  Note that this file can only be called web.config, so don’t worry about choosing a file name for it.

    This will create a commented file containing some of the most common tags. There are others, but these will not be mentioned as we have no use for them.

     

    As you can see, the configuration is separated into common sections that control different aspects of the web server’s behavior in different situations.  The section we are interested in at this point is the authentication section.  You will need to uncomment the following code block and change it so that it appears like this:

    <authentication mode="Forms">

                  <forms name=".ASPXAUTH"
                               loginUrl="login.aspx"
                               protection="Validation"
                               timeout="999999" />

    </authentication>

    This will set the authentication mode to Forms (case-sensitive) and specify the name of the login page that users will need to be redirected to when trying to access a protected resource.  Save this page for now and close the file. What you could do now is add an authorization code block and set it so that all pages in the same folder as the web.config file are protected until a registered user logs in, or specify a particular page that is protected using the location tag.  The problems with these approaches is that either all of your pages are protected (no good for a product catalogue or similar), or that you need to add a new location tag each time you create a protected page (not much fun if there are 50 protected pages, for example.

    More ASP.NET Articles
    More By Dan Wellman


       · Welcome to the third article in the built-in code wizard series. I hope you find it...
     

    ASP.NET ARTICLES

    - Developing a Mini ASP.NET AJAX Server Centri...
    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT