SimpleInjector MVC package and Web API - asp.net-core-webapi

For a Web API project, is the SimpleInjector MVC package the one to use?
Here is a link.

Related

Best architecture for new web site calling existing services (ASP.NET Web API with authentication and authorisation)

What I am trying to achieve:
I currently have mobile apps on top of services and would like to add a web site on top of the same services.
Services details:
ASP.NET Web API project using OAuth (bearer token) and Identity for authentication and authorisation.
Microsoft.AspNet.WebApi 5.2.3
Microsoft.Owin.Security.OAuth 3.0.1
Microsoft.AspNet.Identity.Core 2.2.1
Mobile details:
Xamarin projects.
Xamarin.Forms 2.3.3.193
What architecture should I use for the web site?
Create a new ASP.NET MVC project and call my current services from the MVC controllers? This seems bad because:
I would have 2 layers of controllers (web site MVC controllers calling services API controllers)
I would need to store bearer tokens in cookies
I would need to manage the tokens and cookies expirations
Create a new ASP.NET MVC project and call current services database directly? This seems bad because:
I would have to duplicate the models in the services project and in the web site project
Create a new ASP.NET project and call my current services using ajax? This seems bad because:
I would need to create my own register/login pages
I would need to store bearer tokens in cookies
I would need to manage the tokens and cookies expirations
I would need to say bye to future social authentication (OAUTH2) implementation because I wouldn’t be using OWIN
Thanks,
fcorbeil
If you already have the API a brand new MVC app shouldn't be such a bad choice. If you have your models stored in a different project just reference them to the MVC one. As for the services, them would work perfectly with the new application. This all can be achieved without changing almost nothing to the current implementation.
I am working on a project and using a similar architecture.
I decided to create an Angular project for the website front end and all it does is talk to the Web API. Angular handles the JWT authentication really well. If you've never worked with Angular before, it is really nice to work with.
However, a vanilla ASP.NET MVC web app would work just as well.
It depends on how comfortable you are with Angular, or how willing you are are to learning it! :)

No Individual User Accounts auth option in ASP.NET Core Web API template

I am a bit confused as to why there is no Individual User Accounts authentication option in the latest ASP.NET Core Web API template.
Is it still possible to implement individual user accounts the way that the MVC template does or would it not make sense?
Let's say I am creating a stand-alone web API that is going to have all of my business logic and data layer that accesses the database which has the AspNet Identity tables. I plan on making calls to this API w/ an MVC app.
I know one way of doing this is to create an asp.net MVC app w/ individual user accounts auth and simply build the API right within the MVC app using a controllers/api folder. However, I don't want to do it this way because I want the API to be its own standalone project that can be hosted on a completely different server and accessed by multiple applications, not just an MVC app.
Can someone lead me in the right direction on how authentication typically works in this scenario since there is no template?
Individual User Accounts authentication option for the ASP.NET Core Web API is available in .NET Core 2.0 Preview 1.
Unfortunately .NET Core 2.0 Preview 1 isn't available in VS 2017 release.
But you can install Visual Studio 2017 Preview (you can use it side-by-side with VS 2017 stable version) :
I think you can use IdentityServer4 which allows implementing single sign-on and access control for ASP .NET Core Web APIs using protocols like OpenID Connect and OAuth2. It offers integration with ASP.NET Core Identity and Entity Framework Core.
You will need to install to the following nuget package:
Install-Package IdentityServer4
and add the IdentityServer middleware to the HTTP pipeline:
app.UseIdentityServer();
You can find several quick start samples here or follow this article.

Signalr broadcast from web api

What is the best practice to SignalR broadcast from webapi which is located in another project to mvc application when you install signalr package in the mvc application?
MVC - localhost:8080
API - localhost:8080/api (lives in a different project)
Hubs - Shared class library for Hubs
The problem is, if i install signalr package in MVC application, it doesnt work, but if i install it in API application, it then works.
Any ideas?
You don't need hubs to be shared, hubs are necessary (if you use the Hubs API) only to the broadcaster. You can remove their usage from the MVC project.
Moreover, you do not need the full SignalR package in both. The WebAPI will hardly have its own JS clients (they come from the MVC one), so it is enough to install just the SignalR .NET client library. Same reasoning on the MVC project, that is just a client from a SignalR perspective, so you just need to install the SignalR JS package. I'm assuming you are broadcasting from WebAPI project directly towards the MVC users in their browsers, however if you are trying to achieve a server-to-server broadcasting then you'll need the .NET client library there too, but still no need to share hubs.

Appropirate VS2013 Project Template for AngularJS and Web API 2 Application

This question might be ridiculous. Sorry for that.
I have worked with ASP.NET MVC application. Now I would like to start with AngularJS and ASP.Net Web API 2 in my next web application.
In my previous MVC projects, I selected Empty with the MVC checkbox checked.
What project template should i choose to start with?
Thank you.
There is the AngularJS SPA Template available in MSDN.
It has already 18K downloads, used by many, and constantly updated (last update from two weeks ago).
To add WebAPI 2.0, just right-click on the project > Manage NuGet Packages > Find and reference Microsoft ASP.NET Web API 2.1 Web Host
Then activate it in Startup.cs
Select
New project/Web/Asp.NET web application
Then select WEB API (you can change authentication from here)
Your project is created.
Now open nugget packages manager and update to "Microsoft ASP.NET Web API x.x" (currently 2.2).

How to leverage ServiceStack Session/Cache in ASP.NET 4 Web forms website?

Having read bits and pieces of source code on github ISession and SessionFactory and a bunch of other files (they are gems of coding goodness) I'd like to be able to pull the session component into a legacy VB.Net ASP.NET Web forms website, and have it wrap my existing ServiceStack Caching (implemented Memcached). Is there a NuGet package that I can use?, sort of like MVC MVC PowerPack.
Update
After a bit more digging, I have found Starter ASP.NET which may have the features I need, but I reluctant to install that into our dev main line at the moment.
Have a look at MVC Integration and ServiceStack Integration docs which show how you can use the ServiceStackController in the ServiceStack.Mvc package to access ServiceStack dependencies.

Resources