openiddict asp.net core OpenIdConnectRequest parameter - openiddict

I need OpenIdConnectRequest class inharit and add device id and a extra parameter. How can i add this 2 extra parameter in OpenIdConnectRequest class

var stringParameter = (string) request["string_parameter"];
var longParameter = (long) request["long_parameter"];

Related

what is the usage of name Property in HttpGet ( such as [HttpGet("/products2/{id}", Name = "Products_List")])

In asp.net core, I seen
[HttpGet("/products2/{id}", ***Name = "Products_List")]***
public IActionResult GetProduct(int id)
{
return ControllerContext.MyDisplayRouteInfo(id);
}
what is the usage of name Property in HttpGet (such as[HttpGet("/products2/{id}", Name = "Products_List")])
And, How Can I read/send a Multipart/form-data from/to an apiapicontroller/client?
Yes, it can be used like this. The second parameter of Url.Link is an object.
#Url.Link("Products_List", new { id = 1 })
Also this property RouteUrl can use it.
#Url.RouteUrl("Products_List",new { id=2})
About route name, this is the official introduction:
The route names give the route a logical name. The named route can be used for URL generation. Using a named route simplifies URL creation when the ordering of routes could make URL generation complicated. Route names must be unique application wide.
Route names:
Have no impact on URL matching or handling of requests.
Are used only for URL generation.
If you send a Multipart/form-data. The apicontroller can get it with FromForm.
[HttpGet("routepath")]
public IActionResult get([FromForm]SampleModel model)
{
//...
}
I found that can be used to string uri = Url.Link(“ Products_List”, id = 1);
Is there Some one can give me more detailed information?

How to get #Url.Action value inside a controller

I am using ASP.net core
I can use an Html action inside a view
#Url.Action("GetOptions", "ControllerName", new { id="1"});
However I want to get a string value of it in the Controller.
e.g. something like
string Url= Url.Action("GetOptions", "ControllerName", new { id="1"}).ToString();
In previous versions of MVC you can reference the helper in the controller by
UrlHelper urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);
Basically what I want to do is generate a URL string representation in my controller
In order for the route values to work correctly for me I had to use the static invocation of the url helpers
UrlHelperExtensions.Action(Url, "Details", "Resellers", new { id = 1 })
Edit: The shorthand way of writing this is:
this.Url.Action("Details", "Resellers", new { id = 1 })
Thanks #Learner.

Getting the ID from the Route data in ASP.NET 5 API

I'm implementing an ASP.NET 5 API where I have the following POST method:
[HttpPost("{id}")]
public void Post([FromBody]string value)
{
// Do something
)
For me to process the request, I need both the ID and the string value which will be in the body.
I realize that I can also put the ID in the body but I was wondering if there's a way for me to get the ID directly from the route data -- like in MVC 4/5 where I'd use the following syntax:
var id = (string)this.RouteData.Values["id"];
What's the best way for me to get the ID value in ASP.NET 5? Use the code above or some other way?
You can decorate your parameter with [FromRoute]:
[HttpPost("{id}")]
public void Post([FromRoute] string id, [FromBody] string value) {
// Do something
)

Web API Routing error from RC to RTM with model binding

Upgrading an rc to rtm web api project
Default parameter binding for simple type parameters is now [FromUri]: In previous releases of ASP.NET Web API the default parameter binding for simple type parameters used model binding. The default parameter binding for simple type parameters is now [FromUri].
I believe is the change that is causing me greif.
Well now I'm not so sure. StrathWeb seems to make me thing it should just work as is.
Given this endpoint
[HttpGet]
public HttpResponseMessage Method(string a, string b)
{
...
}
I generate a url on the client using
#Url.RouteUrl("route", new { httproute = "", controller = "Controller", version = "1" })">
to get it to generate the url for this route.
routes.MapHttpRoute(
name: "route",
routeTemplate: "api/v{version}/{controller}/Method",
defaults: new
{
action = "Method",
controller = "Controller",
version = "1"
});
It creates the url fine. The urls looks like
.../api/v1/Controller/Method?optional=z
.../api/v1/Controller/Method?a=x&b=y&optional=z
It throws a 404 when requested. If I remove the parameters a and b in the api controller then it enters the method just fine.
What is the correct way to make these bind?
if you need 'a' and 'b' to be optional, then you would need to make them optional parameters:
public HttpResponseMessage Method(string a = null, string b = null)

Accessing Facebook C# SDK result Object using .NET 3.5 API?

Consider the following in .NET 3.5 (using the Bin\Net35\Facebook*.dll assemblies):
using Facebook;
var app = new FacebookApp();
var result = app.Get("me");
// want to access result properties with no dynamic
... in the absence of the C# 4.0 dynamic keyword this provides only generic object members.
How best should I access the facebook properties of this result object?
Are there helper or utility methods or stronger types in the facebook C# SDK, or should I use standard .NET reflection techniques?
This code sample shows 3.5 usage, without needing the C# dynamic keyword:
// Using IDictionary<string, object> (.Net 3.5)
var client = new FacebookClient();
var me = (IDictionary<string,object>)client.Get("me");
string firstName = (string)me["first_name"];
string lastName = (string)me["last_name"];
string email = (string)me["email"];
var accesstoken = Session["AccessToken"].ToString();
var client = new FacebookClient(accesstoken);
dynamic result = client.Get("me", new { fields = "name,id,email" });
Details details = new Details();
details.Id = result.id;
details.Name = result.name;
details.Email = result.email;
You can also create a facade object around the IDictionary, as explained here.