WebClient in a WP7.1 app called only once

后端 未结 2 1829
陌清茗
陌清茗 2021-01-20 23:27

My problem is:

My WebClient uses a function in the Cloud (http://127.0.0.1:81/Service1.svc/Data).

But it is impossible to call several times (for example to make

2条回答
  •  有刺的猬
    2021-01-20 23:39

    Check your server side to make sure that you aren't allowing caching. If you have the response context in your service, set:

    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    

    Alternatively, if you don't have the ability to do this, send in a changing nonsense parameter on the querystring, something like:

    http://127.0.0.1:81/Service1.svc/Data?nonsense=190AF142-4341-47DC-9CF5-3BC3ACBD02EE
    

    You can either generate and send in a new guid each time, or even use DateTime.Now.Ticks.ToString(). That being said, if you have control over the server side, eliminate caching, as this way is a serious hack.

提交回复
热议问题