Customize JsonPropertyName to include name from Resource file in ASP.NET Core 6 Web API [closed] - asp.net-core

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 days ago.
Improve this question
I have a requirement where the json key value can be changed once the application is deployed.
I'm trying a way to do that by storing the values in Resource file and want it to fetch in [JsonPropertyName("Id")] so that the default framework json and xml serialization is not affected.
[DataContract]
public class ClassRequest
{
[DataMember]
[JsonPropertyName("Id")]
public string id { get; set; }
[DataMember]
public string rev { get; set; }
}
I used json converter and jsonNamingPolicy but neither of them supported default serialization for xml once. Am I missing anything here?
How can I customize JsonPropertyName attribute to have dynamic values from which can be loaded from resource (.rex) file in .NET Core 6?

Related

Generating a report after running a feature file using Runner.runFeature() method [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want to generate a report using below code:
Map<String, Object> result = Runner.runFeature( "classpath:FeatureFiles/Post.feature", args, true);
In args I am passing the test data to the feature file
Also the runFeature() doesn't return any keys related to request and if the feature execution fails no keys are returned to the runner class
You won't get a report this way. This method of running a test is only for those who want to call Karate from Java. Please use the "normal" methods to do "testing".

why Runtime.instance always giving me error [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
hey everyone i'm new at #jade and now i'm trying to write #main class and i have error at "#Runtime rt=new Runtime.instance();" this line ,i added all external jars for jade but still have this problem what dose that mean pLiz help
import jade.core.Runtime;
public class Main {
public static void main(String[] args) {
Runtime rt=new Runtime.instance();
}
instance method is a static method that returns the instance of Runtime class. you needn't use operator new. That is, try to use Runtime rt=Runtime.instance();

How to prevent XSS attacks in WebAPI 2.0 not created as MVC? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
This post was edited and submitted for review 8 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
WebAPI 2.0 not created as MVC
What are the security measures that need to be taken care of to prevent XSS attacks in WebAPI? I have gone through the below article
https://learn.microsoft.com/en-us/aspnet/core/security/cross-site-scripting?view=aspnetcore-3.0 but it is representing MVC application. There is no startup.cs. I have this as my Global.asax.cs
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
System.Web.Http.GlobalConfiguration.Configure(WebApiConfig.Register);
System.Web.Http.GlobalConfiguration.Configuration.Formatters.Clear();
System.Web.Http.GlobalConfiguration.Configuration.Formatters.Add(new JsonMediaTypeFormatter());
AreaRegistration.RegisterAllAreas();
RouteConfig.RegisterRoutes(RouteTable.Routes);
Hangfire.GlobalConfiguration.Configuration.UseSqlServerStorage("HangfireConnection");
}
}
I think this does not apply to Web API or .Net Core. Instead, you can read the Angular docs about XSS here: https://angular.io/guide/security#xss

How to get class attributes in Mono? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I want use attributes in C# code which will work in my project which uses Mono.
It is possible to get class attributes from Mono runtime? And how, if it is possible?
A little explanation:
This is my class with attribute:
[SomeAttribute]
public class SomeClass { /* ... */ }
And somewhere in my C++ code I start Mono and load assembly with this class.
In C++ code I want to discover attributes of this SomeClass and perform some actions. So how can I do this? Can Mono tell what attributes used in this class?
It's going to be difficult to do this from the C++ side, so what you probably want to do is get the attributes as normal from within your C# class:
typeof(SomeType).GetAttributes()
And then call a function from your C++ code to actually access that information.
Using mono to call C# from C/C++

Writing my own api, help please [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have been writing my own api for my site, the api will only allow a consumer to read basic information.
Somebody suggested to me that I gave the consumer a public and private API key. The private API key would be for server side scripts such as php so the public can't view it and use it in a wrong way, and then a public key would be for languages such as javascript. For the public api key they told me I would have to check the original source of the request and match it to a url in my database.
But the way I was going to check the URL the request was coming from was by checking the refer, but I know that the referrer can be changed, so this wouldn't be a good idea.
I'm looking for a way to check the referring URL properly which is very reliable. Or could anyone suggest to me a difference way of doing this API?