私のウェブサイトでは、フォーム認証を使用しています。この目的のためにウェブリクエストを作成したいのですが、cookieContainer の助けを借りています。私のコードはこれです
 string url = HttpContext.Current.Request.Url.AbsoluteUri;
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
    HttpCookie cookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
    Cookie authenticationCookie = new Cookie(
        FormsAuthentication.FormsCookieName,
        cookie.Value,
        cookie.Path,
       HttpContext.Current.Request.Url.Authority);
    req.CookieContainer = new CookieContainer();
    req.CookieContainer.Add(authenticationCookie);
    WebResponse res = req.GetResponse();
しかし、このコードは「The 'Domain'='localhost:300' part of the cookie is invalid.」というエラーをスローします。したがって、このコード行からエラーが発生していることがわかりました。
Cookie authenticationCookie = new Cookie(
    FormsAuthentication.FormsCookieName,
    cookie.Value,
    cookie.Path,
   HttpContext.Current.Request.Url.Authority);
サイトの URL は localhost:300 です。これに対する解決策を見つけることができません。何が問題だったのか教えてもらえますか?