301 Url Redirect Pages don't work in Able
301 Url Redirect Pages don't work in Able
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?
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?
Andrew Jasko
http://www.telephonesystemsforbusiness.com
http://www.telephonesystemsforbusiness.com
Re: 301 Url Redirect Pages don't work in Able
This line is missing ;
place a ; at the end of this line as
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 pageContent ="...."
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>";
Code: Select all
string redirectLocation = "http://www.telephonesystemsforbusiness.com/blah.aspx";
Re: 301 Url Redirect Pages don't work in Able
I fixed the code by putting in the semicolon, but it is still giving me the same error:mazhar wrote:This line is missing ;
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?
Andrew Jasko
http://www.telephonesystemsforbusiness.com
http://www.telephonesystemsforbusiness.com
- 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
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?
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
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
Re: 301 Url Redirect Pages don't work in Able
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
(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
Andrew Jasko
http://www.telephonesystemsforbusiness.com
http://www.telephonesystemsforbusiness.com
Re: 301 Url Redirect Pages don't work in Able
It was the problem i faced too you can see this statement in my comment
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.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
Re: 301 Url Redirect Pages don't work in Able
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.
Andrew Jasko
http://www.telephonesystemsforbusiness.com
http://www.telephonesystemsforbusiness.com
- 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
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
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
Re: 301 Url Redirect Pages don't work in Able
Then please check your blah.aspx you may have provided the wrong language the language must be Language="C#".
Re: 301 Url Redirect Pages don't work in Able
Thanks a ton! That was a pretty dumb oversight on my part. It works now
Andrew Jasko
http://www.telephonesystemsforbusiness.com
http://www.telephonesystemsforbusiness.com
Re: 301 Url Redirect Pages don't work in Able
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?
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?
Re: 301 Url Redirect Pages don't work in Able
So does Any-Name-You-Want-P1504.aspx. The URL rewriter is only looking at the P1504 part.meer2005 wrote:But after renaming both pages
Product-Name-P1504.aspx and Product-P1504.aspx come up as valid.
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.
- 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
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
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