Getting the location from a WebClient on a HTTP 302 Redirect?

后端 未结 4 1996
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 17:08

I have a URL that returns a HTTP 302 redirect, and I would like to get the URL it redirects to.

The problem is that System.Net.WebClient seems to actually follow it,

4条回答
  •  误落风尘
    2020-12-03 17:21

    Also, for someone who just needs the new location, HttpResponseMessage has a RequestMessage property. Sometimes it can be useful, because WebClient doesn't support changing the AllowAutoRedirect property once it's been set.

提交回复
热议问题