【问题标题】:lost session, cant access to download data会话丢失,无法访问下载数据
【发布时间】:2013-06-05 16:14:46
【问题描述】:
public static byte[] BBStorageGetFile(string filePath, int projectId) 
{
    var queryString = QueryStringEncoder.bbs_encode("a=g&p=" + filePath + "&s=" + projectId);
    var url = "http://www.buildbinder.com/base/storageFile.aspx?" + queryString;

    string urlB = HttpContext.Current.Request.Url.ToString();
    if (urlB.Contains("intranet.buildbinder.com"))
    {
        url = "http://intranet.buildbinder.com:8000/base/storageFile.aspx?" + queryString; 
    }

    Uri uri = new Uri(url);

    WebClient webClient = new WebClient();
    webClient.Credentials = CredentialCache.DefaultCredentials;
    webClient.UseDefaultCredentials = true;

    webClient.Headers.Add(HttpRequestHeader.Cookie, "culture");
    webClient.Headers.Add(HttpRequestHeader.Cookie, "mySession");
    webClient.Headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded");
    webClient.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

    byte[] file = webClient.DownloadData(uri);

    return file;
}

【问题讨论】:

  • 看起来您正在使用请求标头发送带有会话值的 cookie,但我看不到您在哪里获取/设置 cookie 值
  • 无法识别cookie,它包含下载的会话信息

标签: c# asp.net-mvc webclient


【解决方案1】:

问题已解决。有人更改了获取存储文件所需的一些参数,此人未与开发团队共享信息。 :(

【讨论】:

    猜你喜欢
    • 2014-12-05
    • 2018-01-27
    • 1970-01-01
    • 2013-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-25
    相关资源
    最近更新 更多