Skip to content

Server properties #50

Answered by scottoffen
alxtr1bal asked this question in Q&A
Feb 26, 2021 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

These are called Locals now instead of DynamicProperties, to match the lingo used in ExpressJS from whence they are insipred. Locals are available on the IRestServer interface and the IHttpContext interface.

string prop1 = server.Locals.GetAs("Prop1");
string prop2 = context.Locals.GetAs("Prop2");
// or
var prop3 = server.Locals.GetAs<string>("Prop3");
var prop4 = context.Locals.GetAs<string>("Prop4");

However, as of the latest release, the IHttpContext interface does not contain an IRestServer property. Which is to say that the context.Server property you reference above doesn't exist anymore. But you can inject it into your class, and you already get this for free!

[RestResource]
public c…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@alxtr1bal
Comment options

@scottoffen
Comment options

@cbritton
Comment options

@scottoffen
Comment options

Answer selected by alxtr1bal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants