1

I have an HTTP endpoint that is like "localhost://helloworld/Dogs" I want a dynamic way to extract the last part of this endpoint, in this case Dogs, and use it as a type in my method. Does anyone know how to do this?

In my code this is what I have so far

string className = ______ ; some code that extracts that entity as a string
var data = await myMethod.GetData<className>(id);

I get the error "className is a variable but it's used as a type. So then I try the following.

Type className = ______ ; some code that extracts that entity as a Type
var data = await myMethod.GetData<className>(id);

And I am still getting the error that says className is a variable but is used as a type. Any ideas?

  • 1
    Do not use the "Dogs" part to identify a type without validation and strict limitation. You could open yourself to some sort of injection vulnerability that allows the client to instantiate an arbitrary type, and who-knows-what from there. – madreflection Oct 25 '22 at 23:04

0 Answers0