|
Subject:
|
webshop - shopping cart - button logic
|
|
Posted By:
|
cpmi
|
Post Date:
|
4/18/2008 3:24:26 PM
|
Hi guys,
What a magnificent resource! Thanks so much for sharing your experience with NET 2.0 in a way that really is useful!
Hope you can help with my question:
In the WebShop Application on the shopping cart page, I noticed that when I press the "Proceed to checkout" button there is some validation going on to check if the user is logged in.
When a user is not logged in the framework tries to redirect the person to "/WebShop/login.aspx"
I would like to know how or where I can change this target URL?
For example
I structured the codebase as a subdirectory off a main application ex: /MyApp/WebShop
So I would like to have non-logged-in users login at: /MyApp/WebShop/login.aspx
In order to make the webshop run in a subdirectory I made the necessary changes to the web.config including changing the "Application Directory from "/" to "/MyApp" and changed the root location where required in each file. 99% of the navigation works great!
I expected to see some button property, or code in the shopping cart, checkout, or the web config where I can specify the target URL where I can send a user to login prior to checkout, but no luck.
What's even more interesting is that when I changed the CausesValidation property on the "proceed to checkout button" to False, I still get the same behavior... I set a breakpoint at the page load for Checkout.aspx, but it never gets hit. Here is the code snippet from the btnCheckout_Click event.
Protected Sub btnCheckout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCheckout.Click Response.Redirect("CheckOut.aspx") <<-- no page_load happens!! End Sub
On Page 274 you wrote:
"Because the checkout page is only accessible by authenticated users, you're taken to Login.aspx first if you're not logged in."
I'm hoping you can elaborate on this and share with us what is happening behind the scenes and perhaps offer an example on which function to override
Thanks! David
|
|
Reply By:
|
Imar
|
Reply Date:
|
4/18/2008 6:56:49 PM
|
Hi there,
By default, .NET Forms authentication always takes you to Login.aspx in the root of your application. Since you run the site as /WebShop, you end up at /WebShop/Login.aspx.
However, you can override this page in web.config like this:<authentication mode="Forms">
<forms loginUrl="~/SomeFolder/SomeFile.aspx" />
</authentication> HtH,
Imar
--------------------------------------- Imar Spaanjaars http://Imar.Spaanjaars.Com Everyone is unique, except for me. Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004 Want to be my colleague? Then check out this post.
|
|
Reply By:
|
cpmi
|
Reply Date:
|
4/19/2008 8:30:34 AM
|
Imar,
I suspected as much
Thanks for clarifying!
Best Regards, David
|
|
Reply By:
|
Imar
|
Reply Date:
|
4/19/2008 8:42:44 AM
|
You're welcome. Have fun with the book!
Imar --------------------------------------- Imar Spaanjaars http://Imar.Spaanjaars.Com Everyone is unique, except for me. Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004 Want to be my colleague? Then check out this post.
|