views:

25

answers:

2

Hey everyone, I have a database which contains my product info, which you can see connected to a catalog page here:

http://www.marioplanet.com/catalog.asp

I would like now, to have product pages created, with the URLs being generated by a certain name in my database.

For example, if you point your browser to the link above, and look at the first product (Mario (Running) - Plush), I would like to have a URL generated based off of that name listed.

So, you would go to http://www.marioplanet.com/Mario_(Running)_Plush.asp or something like that.

Now, I'm not sure how to do this properly, so I really could use some assistance.

What's the easiest way to do this?

+1  A: 

The easiest way would be to buy a shopping cart with the ability already there. That will save you tons of headaches in the PCI compliance arena as well if you're accepting payments. (That's not meant to be a smart-aleck answer. Until you get stuck having to meet compliance and pass audits, you really have no idea what you're in for.) And there are some open source carts that will do it for you as well if you don't want to pay.

I don't know that there is an easy way to do this in classic ASP. With ASP.NET, URL routing is well covered and handled. I believe that Microsoft stopped releasing updates for classic asp long before url rerouting came into vogue. You'd have to write something yourself in something other than classic asp to handle it at the IIS level, I believe.

David Stratton
Totally agree. Acquiring a shopping cart module is much more attractive or better use of a dev's time than writing this new!
p.campbell
He could still have a full ecommerce platform with the actual purchase being offloaded to authorize.net (he wouldn't save anything for PCI compliance) I have developed sites like this for a few customers, but true, he needs to know what he is in for with PCI compliance and audits. Can't half-ass this stuff when other people's money is on the line ;)
Jakub
+1  A: 

Building the URLs is the easy part:

<%
    Dim productName
    Dim categoryName
    Dim url

    Do While rsProducts.EOF = False  
        productName = rsProducts("ProductName")
        categoryName = rsProducts("CategoryName")
        url = "http://www.marioplanet.com/Mario_" + categoryName + "_" + productName + ".asp"
%>      
    <a href="<%Response.Write url%>">
      <%Response.Write categoryName + "-" + productName %>
    </a><br>
<% rsProducts.MoveNext
  Loop   %>

You'd then have to ensure that:

  • those pages are all created/exist on disk
  • setup an IIS handler to ensure they're routed properly.

A Better Route

Suggest you build a URL like:

 http://mysite.com/jackets.asp?p=Vuitton

Then simply make one page for each category (jackets, shoes, cats, horses). Within each, grab the product name/SKU from a querystring parameter. You can use the code above with some slight modification. You'll definitely need to take some measures when querying for Vuitton that it's not a SQL injection attack.

You'd then need to change from .htm to .asp only if the page is to load information from the database.

p.campbell
So.. Once the URLs are built, what is the next step? I have a sample product page (http://www.marioplanet.com/product.htm) but I would need to connect it to my database information, right?
BOSS
AND if you go this route, be darned sure to validate and not open yourself up to SQL injection, XSS, or XSRF attacks.
David Stratton