In fact, you have two questions:
- The difference between System.Web.HttpCookie and System.Net.Cookie
- How to convert from HTTPCookie to Cookie.
Part 1)
This question is really interesting, I still think why there are two classes that look pretty much the same. My initial thought was System.Web.HttpCookie inherits System.Net.Cookie , but this is not how it directly inherits from Object, so these are different classes, but the properties correspond a lot, so this gives hope for a solution to Part 2.
Part 2)
I think that it can be converted to another theoretically, since both are objects, if you fill them correctly, how it will work, here is a little analysis when I compared two classes.
Click to open in a new tab to enlarge

Update: System.Web is intended for use in server applications, and System.Net is for client applications.
Some thoughts:
- Write a method or a static class that can convert one object to another, I did not check all of them, but the properties whose names match, the signature also matches.
- For properties that do not exist in another object, you can use some constant or value, which, as you know, corresponds to a scenario of the
Port type.
Good luck, let me know how you came to the final decision, post the code or link.
Some links This post has some related code
Owais qureshi
source share