来自 SQL Server 数据库的 ASP 动态 URL

发布于 2024-09-17 12:42:27 字数 436 浏览 12 评论 0原文

大家好,我有一个数据库,其中包含我的产品信息,您可以在此处看到它连接到目录页面:

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

我现在希望创建产品页面,并通过数据库中的某个名称生成 URL。

例如,如果您将浏览器指向上面的链接,并查看第一个产品(马里奥(跑步)- 毛绒),我希望根据列出的名称生成一个 URL。

因此,您可以访问 http://www.marioplanet.com/Mario_(Running)_Plush.asp 或类似的内容。

现在,我不确定如何正确执行此操作,因此我确实需要一些帮助。

做到这一点最简单的方法是什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

空心↖ 2024-09-24 12:42:27

最简单的方法是购买已有功能的购物车。如果您接受付款,这也将为您省去 PCI 合规方面的大量麻烦。 (这并不是一个自作聪明的答案。除非您陷入必须满足合规性并通过审核的困境,否则您真的不知道自己要做什么。)并且有一些开源购物车可以为您做到这一点如果您不想付款也可以。

我不知道在经典 ASP 中有一种简单的方法可以做到这一点。使用 ASP.NET,可以很好地覆盖和处理 URL 路由。我相信早在 url 重新路由流行之前,微软就已经停止发布经典 ASP 的更新了。我相信,您必须自己用经典 asp 以外的语言编写一些东西才能在 IIS 级别处理它。

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.

离去的眼神 2024-09-24 12:42:27

构建 URL 是最简单的部分:

<%
    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   %>

然后您必须确保:

  • 这些页面都已创建/存在于磁盘上
  • ,设置 IIS 处理程序以确保它们正确路由。

更好的路线

建议您构建一个类似以下的 URL:

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

然后为每个类别(夹克、鞋子、猫、马)创建一个页面。在每个中,从查询字符串参数中获取产品名称/SKU。您可以使用上面的代码,稍作修改即可。在查询 Vuitton 时,您肯定需要采取一些措施来确保这不是 SQL 注入攻击。

仅当页面要从数据库加载信息时,您才需要从 .htm 更改为 .asp。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文