0

as you all know we simply use

Session["kurd"]="";

or

Cahce.Insert(...)

and its save data in memory; its save data without serialize or any thing like that so we can simply save everything

but its not reliable way to save data;

so may you guys say you can save on database or file but in my case it cant be done, because my data its not serializable, and i can only save it in cache , session , viewdata,viewbage ,... because it dos not need to be serialize data first ; and because of not reliability in session , cache ,... i want way that can save data just like cache and session ,... without serialize data

anyone knows how we can do such thing (save data) in disk i mean save data on hard drive just like session did on memory?

update :

the data type is instance of that class in picture that contain httpclient , httpclienthandeler,deviceinfo,...

enter image description here

update :

how wonderful it is that no one knows how can i save data in hard drive just like what session did in memory no question no serialize no bs, just save it very easy

6
  • Save in text file or so? Commented Jun 1, 2017 at 14:29
  • When you say it's not serializeable, what data are you trying to store? Can you post examples? Commented Jun 1, 2017 at 14:31
  • @wheels73 tanks for your answer i update it Commented Jun 1, 2017 at 14:43
  • @user3250 I want to save it in hard drive in any way or save in ram (for long time like 20 days) Commented Jun 1, 2017 at 14:45
  • @ShoppingCenterCNC - have a look at this answer. This uses Json serialization by creating custom class to wrap httpClient etc.. stackoverflow.com/questions/25335897/… Commented Jun 1, 2017 at 14:52

2 Answers 2

2

Programmatically you can use ObjectDumper.

Or, if you are debugging, you can use a Visual Studio extension called Object Exporter

Sign up to request clarification or add additional context in comments.

Comments

0

i solved this problem HttpClient cant be serialize but i found out that the only thing in HttpClient that we should save in this thread is "CookieContainer" so serlize and deserilze like this

var formatter = new SoapFormatter();
string file = "..\cookies.dat"; 
//
using (Stream s = File.Create (file))
    formatter.Serialize(s, cookies);                            
//
CookieContainer retrievedCookies = null;
using (Stream s = File.OpenRead (file))
    retrievedCookies = (CookieContainer) formatter.Deserialize(s);

so i serialize it and save it and then for new use i create new HttpClient and assign that CookieContainer to HttpClent.CookieContainer

this problem was for Instasharper

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.