how can I generate Static HTML from the ASPX pages?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
15 years ago
hi nopcommerce is pretty good, i'm a newbie programmer and will start to do some design modification to it.

however there's one component I have to change that is the URL rewriting and Static HTML generation.

for example:

instead of: http://localhost/Products/30-intel-desktop-pc.aspx

where can i add the code to make it: http://localhost/computers/intel-desktop-pc.html

note that there'r 2 changes, category belongs to "computers" and get rid of the product ID in front of the "intel-desk....".


My questions is which aspx and ascx pages that generates the URLs ?

Is it in:

1. main.master or [.cs]
2. Category.aspx or [.cs]
3. Product.aspx or [.cs]

I'm a almost complete noob to C# and .net development,

I have an idea of how master page works by looking at MSoft help.

http://i.msdn.microsoft.com/wtxbf3hh.vbMasterPages_merge(en-us,VS.90).gif

but I have no idea how the URL is generated.


Any help would be appreciated.
15 years ago
Jack,

nopCommerce uses a url rewriting component called UrlRewritingNet (read more about it at http://www.urlrewriting.net/149/en/home.html).

The UrlRewritingNet component maps virtual, rewritten friendly urls (like 30-intel-desktop-pc.aspx) to a physical, not quite as friendly url (Product.aspx?ProductID=30).

The important thing to understand is that without the ID in the virtual URL somewhere, you will be unable to pass this to the underlying page and load your products (since QueryString parameters are required).

If your products are unlikely to change, you could add standard ASP.net Url Mappings (you specify these manually in web.config) but I would not recommend it.

I am not sure what you mean by Static HTML generation but I suggest you check out http://www.asp.net/learn. Here you will find some great tutorials on all different aspects of ASP.net including Master Pages.

Hope this helps you.

Ben
15 years ago
But you can customize UrlRewritingNet component to extract requested page name from the URL (i.e. intel-desktop-pc.aspx), then find product by its name (intel desktop pc) and display appropriate page. But this way you can't create products with the same name. And it will be not recommended to rename existing products
15 years ago
Thanks a lot guys, I'm looking at http://www.asp.net now..


The actual thing I'm trying to achieve is this:

see website below:


- http://www.laptopbattery.co.nz/

Click on the **laptop battery** [nav link on the left hand side] take you to

- http://www.laptopbattery.co.nz/Laptop_Batteries.asp

which is a dynamic page.

Then you can click on the first product "PA3399U-1BRS" to go into actual product pages.

- http://www.laptopbattery.co.nz/products.asp?product_no=30438

which is another ASP page....not as good for SEO as a Static HTML page....

NOW the STATIC HTML begins...
________________________________


on the homepage if you click on the top **Product**
this would take you to a sitemap..


Now if you click on **Laptop Batteries** (http://www.laptopbattery.co.nz/Laptop-Batteries/index.htm) [not the one on the left hand side but the middle part of the page]

It will take you to: http://www.laptopbattery.co.nz/Laptop-Batteries/index.htm

Which contains a list of the products in HTML format page....

the first one of them is this:  **BTP-AQJ1** - http://www.laptopbattery.co.nz/Laptop-Batteries/Acer/28223.htm





This is what I'm trying to achieve...where user does NOT have to go through ASPX pages AT ALL....
HTML pages are generated everynight at given time... or using a separate server to serve HTML page.

.ASPX page only on "add to cart", "log in", "orders" etc....

which can be a bit hard to do?

I've googled more about it and found some interesting post, i'll try to see if can be done.

http://stackoverflow.com/questions/56279/export-aspx-to-html

http://www.4guysfromrolla.com/webtech/070601-1.shtml

Am I on the right track? by using the following method??
http://msdn.microsoft.com/en-us/library/system.net.webclient(VS.80).aspx
15 years ago
Can I just ask why you do not want to have .aspx pages in your store? It is very common to use aspx pages in your site. Look at dell.com...
15 years ago
Further to this, you can use UrlRewritingNet to rewrite other file extensions but there is a bit more work involved. I recommend you read their documentation for this but basically you need to allow ASP.NET to handle other extensions. You do this by creating a new handler mapping in IIS for whatever file externsion you want to serve e.g. *.htm.

Then you need to add the following rule to UrlRewritting.config:


      <add name="ProductDetailsRewrite" virtualUrl="^~/Products/([0-9]*)-([\w-]*)\.htm(?:\?(.*))?"
     rewriteUrlParameter="ExcludeFromClientQueryString"
     destinationUrl="~/Product.aspx?ProductID=$1&amp;$3"
     ignoreCase="true" />


And you need to change SEOHelper.cs (in nop.common) to generate urls as *.htm instead of *.aspx.

I have tested this and it works fine. Your pages are displayed as htm.

However, like I say this is quite unnecessary and it unlikely you will have access in a hosted environment to create your own handler mappings.

Thanks,
Ben
15 years ago
The reason I need html or htm is because google seems to like html better than aspx... unfortunately...

I studies top 3~4 google ranked competitors's site and come up with a result.

I got what you are saying...by changing the virtualURL

The thing is I had to write some code to get the engine to generate a HTM page as soon as any products or catagories are added...

well, kind of ruined the purpose of aspx ...

Thank you so much for your help.

Will let you know when the site is up.
15 years ago
Hey Jack,

I totally agree with you on the html, according to google it doesn't matter for the extension, but  few SEO Experts agree with your theory.

Please let me know if you have gotten it accomplished with nopCommerce, I would love to do the same thing as well..


Good luck
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.