I would like to know if it's possible to keep member variables or public properties under a NancyModule.
Here's a simple example of what I think should work but doesn't.
public class MyModule : NancyModule
{
public List<string> MyList { get; set; } = new List<string>();//Problem
public MyModule()
{
#region Get
Get("/index", args => GetIndex("user"));
#endregion
#region Post
Post("/postUser", args => PostUser("user"));
#endregion
}
private int GetIndex(string user)
{
return MyList.IndexOf(user);//Problem
}
private int PostUser(string user)
{
MyList.Add(user);//Problem
return MyList.IndexOf(user);//Problem
}
}
Through debugging, I saw that every time I send a POST or a GET to my running NancyHost, the whole NancyModule is parsed or recalled... So I think my list is reset to a new list of strings every time.
I'm kinda new to nancy and I'm definitely doing something wrong. Is it even possible keep such a variable within this module?