不允许使用用于访问路径"/PoshandDangles/Im-Younger-Than-You-p22/"的HTTP动词POST.在我单击“添加到Paypal的购物车"后.我不确定此错误来自何处,... [英] The HTTP verb POST used to access path '/PoshandDangles/Im-Younger-Than-You-p22/' is not allowed. after I click on the Add to Shopping Cart to Paypal. I'm not sure where this error is coming from,...

查看:62
本文介绍了不允许使用用于访问路径"/PoshandDangles/Im-Younger-Than-You-p22/"的HTTP动词POST.在我单击“添加到Paypal的购物车"后.我不确定此错误来自何处,...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Product : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // Retrieve ProductID from the query string
        string productId = Request.QueryString["ProductID"];
        // Retrieves product details
        ProductDetails pd = CatalogAccess.GetProductDetails(productId);
        // Does the product exist?
        if (pd.Name != null)
        {
            PopulateControls(pd);
        }
        else
        {
            Server.Transfer("~/NotFound.aspx");
        }
        // 301 redirect to the proper URL if necessary
        Link.CheckProductUrl(Request.QueryString["ProductID"]);
    }

    // Fill the control with data
    private void PopulateControls(ProductDetails pd)
    {
        // Display product details
        titleLabel.Text = pd.Name;
        descriptionLabel.Text = pd.Description;
        priceLabel.Text = String.Format("{0:c}", pd.Price);
        productImage.ImageUrl = Link.ToProductImage(pd.Image);
        // Set the title of the page
        this.Title = PoshandDanglesConfiguration.SiteName + ": " + pd.Name;

        // obtain the attributes of the product
        DataTable attrTable =
          CatalogAccess.GetProductAttributes(pd.ProductID.ToString());

        // temp variables
        string prevAttributeName = "";
        string attributeName, attributeValue, attributeValueId;

        // current DropDown for attribute values
        Label attributeNameLabel;
        DropDownList attributeValuesDropDown = new DropDownList();

        // read the list of attributes
        foreach (DataRow r in attrTable.Rows)
        {
            // get attribute data
            attributeName = r["AttributeName"].ToString();
            attributeValue = r["AttributeValue"].ToString();
            attributeValueId = r["AttributeValueID"].ToString();

            // if starting a new attribute (e.g. Color, Size)
            if (attributeName != prevAttributeName)
            {
                prevAttributeName = attributeName;
                attributeNameLabel = new Label();
                attributeNameLabel.Text = attributeName + ": ";
                attributeValuesDropDown = new DropDownList();
                attrPlaceHolder.Controls.Add(attributeNameLabel);
                attrPlaceHolder.Controls.Add(attributeValuesDropDown);
            }

            // add a new attribute value to the DropDownList
            attributeValuesDropDown.Items.Add(new ListItem(attributeValue, attributeValueId));
        }
    }
    protected void AddToCartButton_Click(object sender, EventArgs e)
    {

        // Retrieve ProductID from the query string
        string productId = Request.QueryString["ProductID"];
        // Retrieves product details
        ProductDetails pd = CatalogAccess.GetProductDetails(productId);

        // Retrieve the selected product options
        string options = "";
        foreach (Control cnt in attrPlaceHolder.Controls)
        {
            if (cnt is Label)
            {
                Label attrLabel = (Label)cnt;
                options += attrLabel.Text;
            }

            if (cnt is DropDownList)
            {
                DropDownList attrDropDown = (DropDownList)cnt;
                options += attrDropDown.Items[attrDropDown.SelectedIndex] + "; ";
            }
        }

        // The Add to Cart link
        string productUrl = Link.ToProduct(pd.ProductID.ToString());
        string destination = Link.ToPayPalAddItem(productUrl, pd.Name, pd.Price, options);
        Response.Redirect(destination);
    }
}

推荐答案

修复链接

ASP.NET –不​​允许使用用于访问路径…的HTTP动词 [
Fix link

ASP.NET – The HTTP verb POST used to access path … is not allowed[^]


这是我的web.config文件,请告诉我是否可以.我是ASP.NET和C#的新手,我真的需要一些帮助.如果可以的话,我可以提出所有代码吗?


Here is my web.config file, let me know if it''s ok. I''m new to ASP.NET and C#, I really need some help. May I could put up all the codes if that would help?


<?xml version="1.0" encoding="UTF-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
  </configSections>
  <rewriter>
    <!-- Rewrite department pages -->
    <rewrite url="^.*-d([0-9]+)/?


" ="
" to="~/Catalog.aspx?DepartmentID=


这篇关于不允许使用用于访问路径"/PoshandDangles/Im-Younger-Than-You-p22/"的HTTP动词POST.在我单击“添加到Paypal的购物车"后.我不确定此错误来自何处,...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆