This question already has answers here:
Anyway to get JsonConvert.SerializeObject to ignore the JsonConverter attribute on a property?
(5 answers)
C# JsonConvert using the default converter instead of the custom converter
(1 answer)
Closed 4 years ago.
We are using nSwag and it generates a
Newtonsoft.Json.JsonConverter
attribute on a property, specifically
Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))
Is there anyway to override the attribute at run, to use a different JsonConverter. I've tried adding it to settings.Converters but that does not seem to work.
Related
This question already has answers here:
Why use HTTP PUT and DELETE methods instead of POST?
(4 answers)
Closed 4 years ago.
In CRUD Operations
Many People use [HttpPost] to ( Add, Update , Delete ) .
So : When we use [HttpPost] , [HttpPut] , [HttpDelete] and what is the Different .?
To make it simple :
POST = create
PUT = update (more precisely, full update. For a partial update, use PATCH)
DELETE = delete
More on that here : https://www.restapitutorial.com/lessons/httpmethods.html
This question already has answers here:
Modify request parameter with servlet filter
(8 answers)
Closed 6 years ago.
I have a request which is already coming from a doFilter method, Now I want to clean the parameters of that request that is free from special characters.
After changing the parameters I want to set that parameter and pass it to the same request.
I have tried request.setAttribute till now, that solves the problem but it doesn't sanitizes the parameter i.e: the parameter is not changed.
I have tried many things till now,
Some posts in stackoverflow, but that hasn't helped
How can I clean the parameter and again set it to request wrapper and then pass it to doFilter.
You cannot clean the parameters of that request but you can wrap it with a subclass of HttpServletRequestWrapper that you can pass to the next filter in chain. Original request is passed in constructor.
The wrapper must have as a field a modifiable map initialized with the parameters of the other request (minus those you need to remove) and must extend all the parameters related methods in order to use that map for the implementation (and not those of the original request)
An example with similar requirements: https://stackoverflow.com/a/1422202/1536382
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I want to order results based on a count of collection using Asp.net, web api2 and OData v4.
My url is: url/odata/groupeclients?$expand=Client&$orderby=Client/$count
I get this error :
"The query specified in the URI is not valid. The parent value for a
property access of a property '$count' is not a single value. Property
access can only be applied to a single value."
Is this supported in Web API OData? If not, is there any alternative solution?
Regards,
Hayfa
It's not currently supported; there's an open issue.
As a workaround, you could define an OData function bound to groupeclients that explicitly performs the expansion and ordering. Something like:
[HttpGet]
public IHttpActionResult OrderByClientCount()
{
return this.Ok(data.Include(e => e.Client).OrderBy(e => e.Client.Count));
}
Note that this code is untested and may not even be possible if your IQueryable data source does not support Include (or its equivalent).
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I want to know which is the best convention for controller, action and view naming in ASP.Net MVC
When i create a "Product" Controller, should i name it productController or ProductController ?
By default, visual studio Create ProductController.
But that means the url will be http://mywebsite/Product/xxxx
Or we should not have upper case like this in URLs ?
So i do not know which convention apply.
This is the same for view names and action names...
you can use First latter capital as default MVC does, and for lower case url you can use RouteCollection.LowercaseUrls Property
check below link
https://msdn.microsoft.com/en-us/library/system.web.routing.routecollection.lowercaseurls.aspx
Example:
public static void RegisterRoutes(RouteCollection routes)
{
routes.LowercaseUrls = true;
}
Controller is just a class and should follow class capitalization rules, iow should use PascalCase: https://msdn.microsoft.com/en-us/library/x2dbyw72(v=vs.71).aspx
You can use StyleCop to check your code for such things as casing rules, spaces, etc: https://stylecop.codeplex.com/
But still nobody can prevent you from naming like 'productController'.
Also, if you wish to change appearance of controller name in URL, please check next question and corresponding answers (but usually people ten to use default naming): How to Change ASP.NET MVC Controller Name in URL?
In short, you can do this with RoutePrefixAttribute or by configuring routing (not shown here):
[RoutePrefix("product")]
public class ProductController
{
...
}
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Variable setting in Dreamweaver template in SDL Tridion
We use RenderComponentPresentation (on Tridion 2009) to render internal and external links so that the code base is in only one Dreamweaver template. It would be helpful if we could pass through an optional CSS Class to use when rendering the link.
Any ideas how this could be done?
It is possible to set a value in the RenderContext and then retrieve it in the second Dreamweaver template.
Before calling RenderComponentPresentation set a render context value as follows:
##SetRenderContextVariable("CSSClass","red")##
You will need to have a C# Fragment or TBB to get the variables out of the render context and add them to the package in the second Dreamweaver template. An example would be:
var renderContext = engine.PublishingContext.RenderContext;
foreach (string key in renderContext.ContextVariables.Keys)
{
var value = renderContext.ContextVariables[key] as string;
var item = package.CreateStringItem(ContentType.Text, value);
package.PushItem("RenderContextVariable."+key, item);
}
You should then be able to access the variables within the package using the standard Dreamweaver notation
##RenderContextVariable.CSSClass##
Hope this helps!