Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a dot prefixed cookie uri?

I am trying to pass a Uri of new Uri(".example.com")

Invalid URI: The format of the URI could not be determined.

or new Uri("http://.example.com")

Invalid URI: The hostname could not be parsed.

I need to be able to use the CookieContainer.SetCookies function which only has one overload taking a Uri.

According to this page, .NET 4.0 should support dot prefixed cookies now, but it seems the Uri class does not?

like image 957
AaronLS Avatar asked Nov 23 '25 06:11

AaronLS


1 Answers

In this case, you need to pass a proper uri to the function, and the Uri parser is correctly rejecting the malformed string you are trying to use.

I would advise using the Cookie Constructor that takes 4 parameters - allowing you to set the domain to a dot-prefixed one.

Cookie(string name, string value, string path, string domain);
like image 193
Petesh Avatar answered Nov 24 '25 18:11

Petesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!