0

In Visual Studio 2015, I created a new ASP.NET empty website. I wanted to try this sample shopping cart. I added a very simple index.html:

<!DOCTYPE html>
<html>
<head>
<title>Winery</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="css/style.css" media="screen" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.shop.js"></script>
</head>
<body>
<div id="site">
    <header id="masthead">
        <h1>Winery <span class="tagline">Wines for web developers since 1999</h1>
    </header>
    <div id="content">
        <div id="products">
            <ul>
                <li>
                    <div class="product-image">
                        <img src="images/wine1.jpg" alt="" />
                    </div>
                    <div class="product-description" data-name="Wine #1" data-price="5">
                        <h3 class="product-name">Wine #1</h3>
                        <p class="product-price">&euro; 5</p>
                        <form class="add-to-cart" action="cart.html" method="post">
                            <div>
                                <label for="qty-1">Quantity</label>
                                <input type="text" name="qty-1" id="qty-1" class="qty" value="1" />
                            </div>
                            <p><input type="submit" value="Add to cart" class="btn" /></p>
                        </form>
                    </div>
                </li>   
            </ul>
        </div>
    </div>
</div>
</body>
</html> 

When I click the button, I get this error:

HTTP Error 405.0 - Method Not Allowed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.

This is supposed to POST an item in the cart.html page. (I can post code for the cart.html, but I think the error is happening before that page) If I just open up Windows Explorer and find the index.html and just open that manually in Chrome and click the button the -POST WORKS FINE-, but for reason it doesn't in VS2015 (nor my Azure Web App Service).

When I test the site locally, in VS the process shows 'iisexpress.exe' is running, so I assume IIS Express is what serving up the pages by default. My web.config for this project is the default and looks like this:

<?xml version="1.0"?>
<configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.5.2" />
      <httpRuntime targetFramework="4.5.2" />
    </system.web>
</configuration>

In looking online I've seen that POST could be disabled by default.. is that true?! If so, I'd think many people would have this issue. I can't believe I've had such a hard time finding an answer to this seemingly simple issue.

Also, as I mentioned I am publishing this to an AZURE Web App Service, so I don't think any local changes to IIS config files is going to change anything when I publish. I think I need to change the web.config to make this work in Azure.

I've looked at this post and all of the links in the 'research efforts' section. Nothing. I see all the 'similar questions' to the right as I'm typing this.. they seem related but no solutions work for me.

I appreciate the help.

Atom999
  • 370
  • 3
  • 13

1 Answers1

0

Welp, it seems that I needed to change the file extension to .aspx for the POST to work. Once I changed from .html to .aspx then the post worked as expected. (Seems that the error messages could have SAID that so I didn't waste hours of my life trying to figure out why POST wasn't working)

Atom999
  • 370
  • 3
  • 13