Click here to Skip to main content
15,907,906 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have a problem to make a decision for putting Category/Path on URL Routing. Assume I have some products in my sample Web Application those attached to some categories. For example:

Book1 Attached to -> Category1 | Category2
Book2 Attached to -> Category1 | Category2 | Category3
Book3 Attached to -> Category2 | Category3


And defined routing map for products is:

url: "{controller}/{action}/{languageCode}/{category}/{product}"
defaults: new { controller = "Home", action = "ViewItem" }


So possible routing for Book1 are:

[Domain Name]/Home/ViewItem/en-US/Category1/Book1
[Domain Name]/Home/ViewItem/en-US/Category2/Book1


And possible routing for Book2 are:

[Domain Name]/Home/ViewItem/en-US/Category1/Book2
[Domain Name]/Home/ViewItem/en-US/Category2/Book2
[Domain Name]/Home/ViewItem/en-US/Category3/Book2


I want to save and know current category but have single unique URL for each product.

What I have tried:

I think about using Session Variable or ViewBag even Cookie, But each of them has own limitations and cons. For example ***using cookies may cause some troubles: if set expiration time too small, it may lost current path when user pausing on some pages and if set it too long, may lead user to old browsing path even user requested for home page in new opening browser because of existing cookies(Except that, I'v some experiences with cookies and I believe that is not working precisely all times), About Session and ViewBag I don't know if using them is the best idea, So can anyone share tested solution or good idea?

I will appreciate that.
Posted
Comments
Krunal Rohit 6-May-18 1:56am    
try localStorage.

KR
QMasters 12-May-18 8:52am    
Thanks, but this is not just about storing location. Please read the question again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900