nbarbettini / beautifulrestapi Goto Github PK
View Code? Open in Web Editor NEWBeautiful REST API design with ASP.NET Core and Ion
License: Apache License 2.0
Beautiful REST API design with ASP.NET Core and Ion
License: Apache License 2.0
I have MyResource.cs contains List and List.
Here I am getting an error as follow.
System.Reflection.TargetParameterCountException: Parameter count mismatch. at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index) at CareMentor.Web.Filters.LinkRewritingFilter.RewriteLinksInNestedObjects(IEnumerable
1 objectProperties, Object obj, LinkRewriter rewriter) in C:\Web\Filters\LinkRewritingFilter.cs:line 95
at CareMentor.Web.Filters.LinkRewritingFilter.RewriteAllLinks(Object model, LinkRewriter rewriter) in C:\Web\Filters\LinkRewritingFilter.cs:line 79
at CareMentor.Web.Filters.LinkRewritingFilter.RewriteLinksInNestedObjects(IEnumerable1 objectProperties, Object obj, LinkRewriter rewriter) in C:\Web\Filters\LinkRewritingFilter.cs:line 95 at CareMentor.Web.Filters.LinkRewritingFilter.RewriteAllLinks(Object model, LinkRewriter rewriter) in C:\Web\Filters\LinkRewritingFilter.cs:line 79 at CareMentor.Web.Filters.LinkRewritingFilter.RewriteLinksInArrays(IEnumerable
1 arrayProperties, Object obj, LinkRewriter rewriter) in C:\Web\Filters\LinkRewritingFilter.cs:line 111
at CareMentor.Web.Filters.LinkRewritingFilter.RewriteAllLinks(Object model, LinkRewriter rewriter) in C:\Web\Filters\LinkRewritingFilter.cs:line 76
at CareMentor.Web.Filters.LinkRewritingFilter.d__2.MoveNext() in C:\Web\Filters\LinkRewritingFilter.cs:line 38
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.ResponseCaching.ResponseCachingMiddleware.d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at CareMentor.Web.Startup.<>c.<b__5_0>d.MoveNext() in C:\Web\Startup.cs:line 149
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.d__6.MoveNext()`
First of all thank you.
A great tutorial.
I suggest you take a look at this link.
Just completed (nearly all) your Lynda course (which is excellent by the way) following along using Core 2. I thought you might be interested in a couple of things that break:
In Startup.cs:
// Add ASP.NET Core Identity
services.AddIdentity<UserEntity, UserRoleEntity>()
.AddEntityFrameworkStores<HotelApiContext, Guid>()
.AddDefaultTokenProviders();
needs to go to:
// Add ASP.NET Core Identity
services.AddIdentity<UserEntity, UserRoleEntity>()
.AddEntityFrameworkStores<HotelApiContext>()
.AddDefaultTokenProviders();
and in the UsersController.cs:
var canSeeEveryone = await _authzService
.AuthorizeAsync(User, "ViewAllUsersPolicy");
if (canSeeEveryone)
{
users = await _userService.GetUsersAsync(
pagingOptions, sortOptions, searchOptions, ct);
}
Error CS0029 Cannot implicitly convert type 'Microsoft.AspNetCore.Authorization.AuthorizationResult' to 'bool' bodimecore ...\Controllers\UsersController.cs error
Which I've not had time to look at yet. (Monday hopefully).
Thanks again for the great course.
Solution file not opening. Did you created over 2017 VS?
I have enjoyed your course on Lynda.com building and securing restful api in asp.net core. I was hopping this is the same project because I got a 500 error trying to get the token using the final project! I would appreciate if you try it and let me know how I fix it.
Thanks
I'm trying to follow the example, but it seems that app.UseExceptionHandler
it's called only when I remove app.UseAuthorization
, but I do need UseAuthorization
. What could I be missing?
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
// Serialize all exceptions to JSON
var jsonExceptionMiddleware = new JsonExceptionMiddleware(app.ApplicationServices.GetRequiredService<Microsoft.AspNetCore.Hosting.IHostingEnvironment>());
app.UseExceptionHandler(new ExceptionHandlerOptions { ExceptionHandler = jsonExceptionMiddleware.Invoke });
app.UseHsts();
app.UseRouting();
app.UseHttpsRedirection();
app.UseCors(x => x
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseResponseCaching();
}
When I have status 401 for example, It should be calling JsonExceptionMiddleware.Invoke
before the request response, but the body it's empty.
Those actions are mostly short-running. Does it add any benefit?
I cannot navigate to this link : https://ionwg.org/ via chrome.
ionwg.org uses an unsupported protocol.
ERR_SSL_VERSION_OR_CIPHER_MISMATCH
Hi, really nice tutorial, appreciate your contribution!
I would suggest one change:
CreateUserQuery
CreatePostQuery
Use CreateUserCommand and CreatePostCommand naming instead.
If you want to approach a CQRS design maybe also separate queries from commands using an abstract interface for each of them.
Cheers!
Am I missing something? There seem to only be GET routes, no post or put or patch examples?
Right now the API is unauthenticated. An example of how to do API security for a RESTful API would be sweet!
I'm not sure if i'm right but when using Automapper projection and use mapfrom in mapping profile we get an exception below:
The client projection contains a reference to a constant expression of 'Domain.Config.Link'. This could potentially cause a memory leak; consider assigning this constant to a local variable and using the variable in the query instead. See https://go.microsoft.com/fwlink/?linkid=2103067 for more information.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.