301 Url Redirect Pages don't work in Able

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
ajasko
Lieutenant (LT)
Lieutenant (LT)
Posts: 53
Joined: Sun Sep 23, 2007 8:04 pm
Contact:

301 Url Redirect Pages don't work in Able

Post by ajasko » Sat Jul 19, 2008 9:06 pm

I need to use 301 redirect pages because I have switched my shopping cart to Able Commerce and the urls for all of my products have changed. I have tried to create the redirect pages, but they do not work in Able Commerce because of the code. With the usual plain asp.net code for 301 redirects, I got "Object reference not set to an instance of an object," errors, because AbleCommerce is trying to do a whole bunch of prerender things that are not allowing the redirect.

I tried some modified code that Logan gave me, but it still does not work:

<script runat="server">
private void Page_Init(object sender, System.EventArgs e)
{
string redirectLocation = "http://www.telephonesystemsforbusiness.com/blah.aspx";
Response.Clear();
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", redirectLocation);
string pageContent = "<html><head><title>Object moved</title></head><body><h1>Object Moved</h1>This object may be found at <a href=\"{0}\">{0}</a>.</body></html>"
Response.Write(string.Format(pageContent, redirectLocation));
Response.End();
}
</script>

Here is the Error:

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30205: End of statement expected.

Source Error:

Line 1:
Line 2: <script runat="server">
Line 3: private void Page_Init(object sender, System.EventArgs e)
Line 4: {
Line 5: string redirectLocation = "http://www.telephonesystemsforbusiness.com/blah.aspx";

Source File: E:\hshome\telesystems\telephonesystemsforbusiness.com\blah.aspx Line: 3


Maybe some minor tweak needs to be made to this code that we overlooked? I don't really know programming. Anyone know what the right code might be for doing 301 redirects with Able Commerce?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: 301 Url Redirect Pages don't work in Able

Post by mazhar » Mon Jul 21, 2008 4:46 am

This line is missing ;

Code: Select all

string pageContent ="...."
place a ; at the end of this line as

Code: Select all

string pageContent = "<html><head><title>Object moved</title></head><body><h1>Object Moved</h1>This object may be found at <a href=\"{0}\">{0}</a>.</body></html>";
and also make sure that you are providing URL to a valid page instead of some blah.aspx in the following line of code where ever you used this code

Code: Select all

string redirectLocation = "http://www.telephonesystemsforbusiness.com/blah.aspx";

User avatar
ajasko
Lieutenant (LT)
Lieutenant (LT)
Posts: 53
Joined: Sun Sep 23, 2007 8:04 pm
Contact:

Re: 301 Url Redirect Pages don't work in Able

Post by ajasko » Mon Jul 21, 2008 8:53 am

mazhar wrote:This line is missing ;
I fixed the code by putting in the semicolon, but it is still giving me the same error:

Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30205: End of statement expected.

Source Error:

Line 1:
Line 2: <script runat="server">
Line 3: private void Page_Init(object sender, System.EventArgs e)
Line 4: {
Line 5: string redirectLocation = "http://www.telephonesystemsforbusiness.com/blah.aspx";


Source File: E:\hshome\telesystems\telephonesystemsforbusiness.com\blah.aspx Line: 3

Also, the url http://www.telephonesystemsforbusiness.com/blah.aspx is valid: it is a test page. Could you maybe try to make a test 301 redirect page on your Able Commerce server and see if you can get it to work?

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: 301 Url Redirect Pages don't work in Able

Post by jmestep » Mon Jul 21, 2008 9:17 am

What kind of page is blah.aspx? A category, product,webpage? If so, it needs one of those ids to run, like category_id.
Where are you putting this code? On your old site pages? Please expain the process--how are people getting to the page on the new site if that is where you have the code?
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
ajasko
Lieutenant (LT)
Lieutenant (LT)
Posts: 53
Joined: Sun Sep 23, 2007 8:04 pm
Contact:

Re: 301 Url Redirect Pages don't work in Able

Post by ajasko » Mon Jul 21, 2008 10:02 am

Good point! Ok, I am redirecting an old product page (blah.aspx) to a new product page on Able
(http://www.telephonesystemsforbusiness. ... -P474.aspx).

So now the code on blah.aspx looks like this:

<script runat="server">
private void Page_Init(object sender, System.EventArgs e)
{
string redirectLocation = "http://www.telephonesystemsforbusiness. ... -P474.aspx";
Response.Clear();
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", redirectLocation);
string pageContent = "<html><head><title>Object moved</title></head><body><h1>Object Moved</h1>This object may be found at <a href=\"{0}\">{0}</a>.</body></html>";
Response.Write(string.Format(pageContent, redirectLocation));
Response.End();
}
</script>


But the error stays the same:

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30205: End of statement expected.

Source Error:

Line 1:
Line 2: <script runat="server">
Line 3: private void Page_Init(object sender, System.EventArgs e)
Line 4: {
Line 5: string redirectLocation = "http://www.telephonesystemsforbusiness. ... -P474.aspx";

Source File: E:\hshome\telesystems\telephonesystemsforbusiness.com\blah.aspx Line: 3

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: 301 Url Redirect Pages don't work in Able

Post by mazhar » Mon Jul 21, 2008 10:28 am

It was the problem i faced too you can see this statement in my comment
and also make sure that you are providing URL to a valid page instead of some blah.aspx in the following line of code where ever you used this code
In fact after putting semicolon the code was still causing the problem and i found that it was because of the "blah.aspx". As that page does not exist and it was throwing this error. Then i checked this for the basket page and it worked fine.

User avatar
ajasko
Lieutenant (LT)
Lieutenant (LT)
Posts: 53
Joined: Sun Sep 23, 2007 8:04 pm
Contact:

Re: 301 Url Redirect Pages don't work in Able

Post by ajasko » Mon Jul 21, 2008 11:00 am

The page blah.aspx does exist but not in the database. It is not a product page, it is a simple aspx page in the main directory with nothing else on it but this code. It is for a page on my old site to be redirected to a product url on the new site.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: 301 Url Redirect Pages don't work in Able

Post by jmestep » Mon Jul 21, 2008 11:50 am

I made a test page with this on it, and it worked. Did you have the Page directive on yours?

Code: Select all

<%@ Page Language="C#" MasterPageFile="~/Layouts/Scriptlet.master" Inherits="CommerceBuilder.Web.UI.AbleCommercePage" Title="Redirect" %>

<script runat="server">
   
    
    protected void Page_Load(object sender, EventArgs e)
    {
        string redirectLocation = "http://www.telephonesystemsforbusiness.com/Avaya-2410-IP-Telephone-P474.aspx";
        Response.Clear();
        Response.Status = "301 Moved Permanently";
        Response.AddHeader("Location", redirectLocation);
        string pageContent = "<html><head><title>Object moved</title></head><body><h1>Object Moved</h1>This object may be found at <a href=\"{0}\">{0}</a>.</body></html>";
        Response.Write(string.Format(pageContent, redirectLocation));
        Response.End();
    }
</script>
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: 301 Url Redirect Pages don't work in Able

Post by mazhar » Mon Jul 21, 2008 11:57 am

Then please check your blah.aspx you may have provided the wrong language the language must be Language="C#".

User avatar
ajasko
Lieutenant (LT)
Lieutenant (LT)
Posts: 53
Joined: Sun Sep 23, 2007 8:04 pm
Contact:

Re: 301 Url Redirect Pages don't work in Able

Post by ajasko » Wed Jul 23, 2008 8:07 am

Thanks a ton! That was a pretty dumb oversight on my part. It works now

meer2005
Captain (CAPT)
Captain (CAPT)
Posts: 245
Joined: Wed Feb 09, 2005 2:00 pm

Re: 301 Url Redirect Pages don't work in Able

Post by meer2005 » Thu Aug 07, 2008 2:32 pm

Seems how AC 7 really only works with the URLs with the product number only in the product page urls (Product-Name-P1504.aspx), how does one go about doing 301 redirects from the AC 5.5 pages to the new AC 7.0 pages?

Example:

Old 5.5 URL for product number 1504: Product-Name-P1504C46.aspx (includes category number)

Needs to be redirected to the new URL format, without the category number: Product-Name-P1504.aspx

If you go to an AC 7 site, both Product-Name-P1504C46.aspx and Product-Name-P1504.aspx work and take you to the same page, but with different URLs. Why is this? Is there any way to clear the application cache so Product-Name-P1504C46.aspx isn't a valid page? Or just any way to kill this format (Product-Name-P1504C46.aspx) completely?

Bottom line, I need some way to clear all the Product-Name-P1504C46.aspx pages out of the cache or where ever they are stored so it isn't a valid page when it shouldn't be.

Same thing with renaming pages. Why does the old page stay valid?

Example:

If the name of my product is "Product Name," then the url would be something like this:
Product-Name-P1504.aspx

If I rename item "Product Name" to Just "Product," the url would be something like this:
Product-P1504.aspx

But after renaming both pages
Product-Name-P1504.aspx and Product-P1504.aspx come up as valid.

In AC 5.5, I think I recall a feature that was called something like generate seo rules that would clear the cache? Anything like that in 7?

afm
Captain (CAPT)
Captain (CAPT)
Posts: 339
Joined: Thu Nov 03, 2005 11:52 pm
Location: Portland, OR
Contact:

Re: 301 Url Redirect Pages don't work in Able

Post by afm » Thu Aug 07, 2008 5:32 pm

meer2005 wrote:But after renaming both pages
Product-Name-P1504.aspx and Product-P1504.aspx come up as valid.
So does Any-Name-You-Want-P1504.aspx. The URL rewriter is only looking at the P1504 part.

I don't know how you would go about recognizing the old URL format and redirecting to the new format. They are almost identical and clearly compatible.

You could possibly generate a list of every possible URL on your old site along with the corresponding new URL and then implement a 3rd party URL rewriter that executes earlier in the pipeline to redirect from one to the other.
Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: 301 Url Redirect Pages don't work in Able

Post by jmestep » Fri Aug 08, 2008 8:41 am

The redirect does work from an able 5.5 store- it keeps the C in the URL at the redirect, but it still gets to the right page. I'll pm you a link to check.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

Post Reply