Register new route best practice

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
Hi,

Im just starting to learn the structure of nopcommerce, and would like to know best practices for modifications.

If I want to create a custom page similar to how contactus, sitemap etc work, do i just add the route to routeprovider.cs,  if I do any upgrades to core later on would my custom route get over written?

Or do I create a new file in infrastructure eg: customroutes, with a new partial class based on routeprovider and add my routes in there, or do i need to create a simple plugin to register the route?

Thanks.
3 years ago
Hi,
I would recommend you to create plugin for your code. It will be very easy if you want to add more functionalities in your plugin and of course it's very easy to update with new nopCommerce version.

Try to isolate your code as possible as you can for better maintenance.

Thank you.
3 years ago
Thank you for your reply Pratik.

If you dont mind, could you clarify this point from the documentation for me please:

Important note: After each project build, clean the solution before making changes. Some resources will be cached and can lead to developer insanity.

I read it as being if I am going to make any changes to the source I should always do a clean first? What if I forget, what could be the worst that could happen?

Thanks.
3 years ago
Nothing bad can happen if you dont clean. In fact if you are working in Visual Studio you dont need to always clean. Build the plugin and as long as the project builder is correct, files are copied to the output directory. Although once every now if something goes wrong and you may need to clean the project.

As it says some resources are cached so if you you change those when it is running then you may need to clear the cache. Playing with CSS while running may need to clear the browser cache.

Same when changing resoures in production need to clean the cache. Of you change .cshtml in production you need to restart the application / app pool as files are compiled in at runtime.

Developer insanity is more caused by your own bad logic, understanding or incorrect coding :)
3 years ago
cheers for that mate : )
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.