Member 8351861 Ответов: 5

Http-команду, до доступ к пути '/PoshandDangles/им-моложе-чем-вы-п22/' - не допускается. после того, как я нажму на кнопку Добавить в корзину покупок для 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);
    }
}

5 Ответов

Рейтинг:
2

rameshcse2005

Add an index.htm with below re-direct lines

<html>
  <head>
    <meta http-equiv="Refresh" content="0; url=Default.aspx" />
  </head>

</html>


Рейтинг:
1

Member 8351861

Вот мой файл web.config, дайте мне знать, если все в порядке. Я новичок в этом деле ASP.NET и C#, мне действительно нужна помощь. Могу я выставить все коды, если это поможет?


<?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=$1" processing="stop" />
    <rewrite url="^.*-d([0-9]+)/page-([0-9]+)/?$" to="~/Catalog.aspx?DepartmentID=$1&amp;Page=$2" processing="stop" />
    <!-- Rewrite category pages -->
    <rewrite url="^.*-d([0-9]+)/.*-c([0-9]+)/?$" to="~/Catalog.aspx?DepartmentId=$1&amp;CategoryId=$2" processing="stop" />
    <rewrite url="^.*-d([0-9]+)/.*-c([0-9]+)/page-([0-9]+)/?$" to="~/Catalog.aspx?DepartmentId=$1&amp;CategoryId=$2&amp;Page=$3" processing="stop" />
    <!-- Rewrite product details pages -->
    <rewrite url="^.*-p([0-9]+)/?$" to="~/Product.aspx?ProductId=$1" processing="stop" />
  </rewriter>
  <appSettings>
    <add key="PaypalUrl" value="https://www.paypal.com/xclick" />
    <add key="PaypalEmail" value="Test@example.com" />
    <add key="PaypalCurrency" value="USD" />
    <add key="PaypalReturnUrl" value="http://www.poshanddangles.com" />
    <add key="PaypalCancelUrl" value="http://www.poshanddangles.com" />
    <add key="MailServer" value="mail server address" />
    <add key="MailUsername" value="mail username " />
    <add key="MailPassword" value="mail password" />
    <add key="MailFrom" value="mail address" />
    <add key="EnableErrorLogEmail" value="false" />
    <add key="ErrorLogEmail" value="errors@example.com" />
    <add key="ProductsPerPage" value="6" />
    <add key="ProductDescriptionLength" value="60" />
    <add key="SiteName" value="PoshandDangles" />
    <add key="CartPersistDays" value="10" />
  </appSettings>
  <connectionStrings>
    <add name="PoshandDanglesConnection" connectionString="Server=(local)\SqlExpress; Database=PoshandDangles; Integrated Security=SSPI" providerName="System.Data.SqlClient" />
    <remove name="LocalSqlServer" />
    <add name="LocalSqlServer" connectionString="Server=(local)\SqlExpress;Database=PoshandDangles; Integrated Security=SSPI" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <location path="AdminDepartments.aspx">
    <system.web>
      <authorization>
        <allow roles="Administrators" />
        <deny users="*" />
      </authorization>
    </system.web>
  </location>
  <location path="AdminCategories.aspx">
    <system.web>
      <authorization>
        <allow roles="Administrators" />
        <deny users="*" />
      </authorization>
    </system.web>
  </location>
  <location path="AdminProducts.aspx">
    <system.web>
      <authorization>
        <allow roles="Administrators" />
        <deny users="*" />
      </authorization>
    </system.web>
  </location>
  <location path="AdminProductDetails.aspx">
    <system.web>
      <authorization>
        <allow roles="Administrators" />
        <deny users="*" />
      </authorization>
    </system.web>
  </location>
  <location path="AdminProductAttributes.aspx">
    <system.web>
      <authorization>
        <allow roles="Administrators" />
        <deny users="*" />
      </authorization>
    </system.web>
  </location>
  <!-- Only administrators are allowed to access ShoppingCartAdmin.aspx -->
  <location path="AdminShoppingCart.aspx">
    <system.web>
      <authorization>
        <allow roles="Administrators" />
        <deny users="*" />
      </authorization>
    </system.web>
  </location>
  <!-- Only administrators are allowed to access AdminOrders.aspx -->
  <location path="AdminOrders.aspx">
    <system.web>
      <authorization>
        <allow roles="Administrators" />
        <deny users="*" />
      </authorization>
    </system.web>
  </location>
  <!-- Only administrators are allowed to access AdminOrders.aspx -->
  <location path="AdminOrderDetails.aspx">
    <system.web>
      <authorization>
        <allow roles="Administrators" />
        <deny users="*" />
      </authorization>
    </system.web>
  </location>

  <system.web>
      <webServices>
          <protocols>
              <add name="HttpPost" />
          </protocols>
      </webServices>

      <roleManager enabled="true" />
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US" />
    <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
    <compilation debug="true" targetFramework="4.0" />
    <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
    <authentication mode="Forms">
      <forms name="PoshandDanglesLogin" loginUrl="Login.aspx" path="/" protection="All" timeout="60" />
    </authentication>
    <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
    <customErrors mode="Off" defaultRedirect="~/Oops.aspx">
      <error statusCode="404" redirect="~/NotFound.aspx" />
      <error statusCode="500" redirect="~/Oops.aspx" />
    </customErrors>
    <pages theme="PoshandDanglesDefault" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
    <httpModules>
      <add type="Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter" name="UrlRewriter" />
    </httpModules>
  </system.web>
  <!--
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
    </modules>
        <handlers>
            <remove name="PageHandlerFactory-ISAPI-4.0_32bit" />
            <add name="PageHandlerFactory-ISAPI-4.0_32bit" path=".aspx" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
        </handlers>
  </system.webServer>
</configuration>


Рейтинг:
0

damianpawski

Привет

У меня была та же проблема, которую я добавил после перезаписи в свой web.config

<rewrite url="^.*-p([0-9]+)/.*=([0-9]+)/?$" to="~/Product.aspx?ProductId=$1" processing="stop" />

и это прекрасно работает.


Рейтинг:
0

Member 8351861

Спасибо за ссылку, я видел это раньше, но я использую IIS7 ASP.Net 4.0 и я не смог найти это отображение asp.isapi.dll.