开发者

ASP dynamic URLs from SQL Server database

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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜