OWIN Katana, Webapi, MVC all in separate projects - asp.net-mvc-5

I have a project that currently is using MVC5, WebApi2 and OWIN. It has become quite a bit larger than I anticipated and I am looking into splitting it up into separate projects. I will move the business logic and data access into a new project but then I was thinking about splitting the webapi and mvc into 2 more projects.
Really, there is very little MVC. Basically just the /index.cshtml and the /Help page. Everything else is Durandal. I was thinking if I were to move that out of the main project then then I would have some flexibility with hosting. It just seems that the MVC part of the application is heavy and not needed.
I would then make a webapi project, which is really where everything is happening anyway.
I have been considering using the OWIN pipeline and wrapping the webapi as middleware and the mvc project as middleware. Then I could have multiple startup classes that could be used for different configurations. One thing that I like about this idea is the webapi and the mcv app could be used individually or together. In either case, because of the nature of OWIN, it can be self hosted or run through IIS.
Now my question is...
Does this really make sense? There are potential cases for running the webapi service on its own. Are there any potential losses I will have to take in a setup like this?
Thanks.

#mnfact :- I would refer you to create two separate solutions one with the WebApi2,OWIN and another with the MVC5. It would be the good designing. Kindly go through the link :- " MVC & Web Api projects within same Solution "
I think there are can be issues while providing authentication to the WebApi and MNV5 project separately. Same for the datacontext you have to solve the Dependency between the controllers.
Hope this help you!

Related

In ASP.NET Core 6 Razor Pages how do I CRUD the Users and Roles?

I have followed this monumental tutorial Create an ASP.NET Core web app with user data protected by authorization which gave me a good oversight for Authorization.
However I still can't find a way to simply CRUD Roles and Users. Anywhere! The best I have seen are tutorials in MVC on making a list of users and roles. But that conflicts with my existing program.
There are a number of old tutorials, some still on the MS website, for MVC, webforms, etc, but nothing for Core 6 Razor pages.
Is there a CRUD of Core 6 ASPNetRoles and ASPNetUsers? If not why not? Is it a security issue? Does everyone roll their own? Is it so easy that I just don't get it?
Edit: As an update, I found this excellent resource https://github.com/mikebrind/Razor-Pages-In-Action/tree/main/Chapter10 if anyone else is looking for guidence.
They still exist, except much less is included in the template.
If you start with the .NET 6 Templates ex;
MVC - dotnet new web --auth individual
Razor Pages - dotnet new razor --auth individual
Blazor - dotnet new blazor --auth individual
It will kick you out a template with: Bootstrap CSS, Entity Framework and a database with the Identity Library and a Razor Class Library for the Register and sign in, etc.
From here, you are provided abstractions like IdentityUser, IdentityRole and base classes like RoleManager. There aren't any implementations or frontend code provided out of the box.
These abstractions give you the flexibility to opt-in, and tailor to suit your organizational requirements. CRUD is rather simple and will take very little effort to implement.
Reference Source for CRUD RoleManager in MVC -> https://github.com/procodeguide/Sample.Identity.Roles/blob/main/ProCodeGuide.Sample.Blog/Controllers/RoleController.cs

Any advantage in removing ASP.NET references from a web api project?

We have a ASP.NET Web Api project.
A colleague has removed the Microsoft.AspNET references.
We use IIS web hosting.
I would like to use swagger as api help replacement.
But Swagger or the .NET package Swashbuckle/Swagger comes in the CORE with Microsoft asp.net dependencies.
My colleague said we can not use this swagger.
I would like to know what the real problem is (colleague does not really say...) or what the advantage is of a decoupled web api project with asp.net dependecies?
I mean we host on IIS...
I would like to know what the real problem is (colleague does not
really say...)
Not code but, I think this is the first problem. Try to get your "colleague" to explain "why" it's better. (Not just cool code, but also mem/cpu footprint, team-capability-of-take-over, future path, etc.) Good code is maintainable by any qualified developer, not extremely complex and 'understood by only the one'.
what the advantage is of a decoupled web api project with asp.net
dependecies?
Decoupling is a good thing. First, "if you don't use it, don't reference it". To many projects end up having completely useless coupled libraries. Why? Because the "new project" template had them when the project was first created!
In the specific case of Asp.Net core libraries: The current Asp.Net is old, and a new version is on the way. One that will consolidate the knowledge and techniques of "Asp.Net, MVC, WebAPI, OData, OAuth, etc, etc). https://msdn.microsoft.com/en-us/magazine/dn913182.aspx
This means breaking changes are coming.
Not being coupled to the core libraries that are going to change seems like a good idea. If you want to move to this next version you'll have a lot less problems if you're not relying on 'old Asp.Net' functionality.
My colleague said we can not use this swagger.
I think the better way of saying it is; "We will not use anything that tightly couples us to Asp.Net core libraries again since we're decoupling from it".

How to setup the location element in web.config for Parallel with other Frameworks

I'm reading [https://github.com/ServiceStack/ServiceStack/wiki/Run-servicestack-side-by-side-with-another-web-framework][1] but it doesn't explain enough or give a solution example (or I just don't know of an an example in the SS github site I can see something like this working with ASP.NET MVC and using that location element).
So I don't understand this custom service path from a Solution/Project perspective in the location element.
Here's how my current Solution looks:
Just a bit about the above pic. The MVC project that I created is that one I outlined in orange. I added then the ServiceStack projects I'll need to work with (we want to work with the actual code from SS, not binaries).
So now I'm looking back at the web.config that sits in my MVC proj as you can see in the pic which is open. So this "/api" for example, so what is that referring to? Like Our "Service" that we are gonna expose is in a different project ..you see that at the top, the project Called ServiceInterface.
I'm trying to understand how this works for the location. Location of what and how would I set that up in my solution here just for example?
#CoffeeAddict
sorry, but as a simple ServiceStack user like you, I feel the need to tell you
that it is good to have a lot of questions, but
Here is not private support, please make meaningful questions for all the others.
Don't waste time of mythz. We expect from him to deliver the new ServiceStack version.
If he is successful, all of us we will be too.
P.M
down in the page that you mentioned Run servicestack side by side with another web framework
there is an example of config Example config file for Asp.Net 3.5 in /api.
Maybe it is not appropriate for you, but it is not true, that there is not example.
Also, these questions
Running ServiceStack side by side with MVC
Service Stack on MVC4
the following is from you at Sept 25. It was answered from mythz.
Setting up Web.config to work Side-by-Side with ASP.NET MVC 4
Maybe you are not satisfied of course, but what to do about ? nothing.
check this also
ServiceStack.Host.Mvc / content / README.txt
Here
a user's blog post A mixed ASP.Net MVC 4 and ServiceStack reference project
and his sample project in githup DiffStack

Converting ASP.NET MVC Project to ServiceStack.Razor

I have an existing ASP.NET MVC 4 project that already uses ServiceStack for REST services, and I just read all about ServiceStack.Razor and would love to move the entire project onto ServiceStack. Right now there is only one controller and view besides the built-in AccountController, and that controller just returns the view and the view is really just HTML; everything else is HTML/CSS/JS + ServiceStack REST.
The only real legacy constraint here is that this new app still needs to make use of SimpleMembership. At present I'm using a custom auth provider to authenticate against SimpleMembership and I would like to be able to continue to do so.
So, what would be the best recommended path to achieve this end? Can I get what I want by modifying my existing project by removing some references, or should I start fresh with an empty ASP.NET app and move the old stuff into it? Can I have SimpleMembership without introducing dependencies that will step all over ServiceStack.Razor?
If you were to start a new solution using only servicestack then MVC would never be there to get in the way.
I use servicestack.razor and love it. It is a lot simpler than MVC in my opinion. Moving everything to the new solution is pretty much going to be copy and paste since what you have works. I wouldn't hesitate and would make the move sooner than later. In the end you are not gaining anything from MVC. You only gain using servicestack. A big deal for me is self-hosting and eventually moving to mono.
This is a question that will have answers based off opinion so I suspect you will receive a few. I have not personally performed such a migration so this is only opinion but is how I would approach it. However, my recommended approach would be:
Retain the existing application/ Given its current simplicity, creating a new app and moving existing items into it seems unnecessary.
You should be able to use your existing auth solution via SimpleMembership and use ServiceStack.Razor. I would proceed as such however it does depend on what other ServiceStack features you may use which could cause conflict. A ServiceStack expert could comment more on this. Even if that did occur, you would be able to work around it relatively easy. At worst, implementing a simple handler would get around almost all issues from an authentication perspective.
Working with different razor engines is relatively easy to do and you can use/enable/disable existing or new build engines via a few lines of code. See here for an example. This should alleviate any concerns around dependencies of other built in or custom engines.
Consider looking at ASp.Net 4.5.1/VS 2013 (since your project is in early days) as it has enhanced membership support and is moving to a more "less dependent" model of components via the Owin stack Asp.Net 4.5.1 and VS 2013. Katana is a microsoft project that also provides some Owin based authentication components see here and here which you could use now and this would remove a lot of dependencies and enable you to migrate other framework with relative ease. Downside is that Katana/Owin has a little ramp up time/learning curve. Again, given your project is in its formative days I would recommend looking into Katana and the ASP.Net vNext stuff as this will make it easier for you and means you dont have to migrate to the new version once it is released.

Can existing .net application be converted to MonoDroid?

Can existing .net application(in C#) be converted to MonoDroid? or
Can we port an existing .NET web app to Android using MonoDroid?
MonoDroid is intended to allow you to develop applications in C# as opposed to Java; not as a means to drop an existing application into place.
You asked about a web app, but I'm assuming you mean an ASP.NET web app, which wouldn't map to the Android API, and couldn't simply be copied over. Even taking your HTML and dropping it into something like Titanium would still require a lot of JS tweaking to make it work.
I have a feeling you're looking at a re-write. Maybe if you can provide more details (is this an ASP.NET app, etc.), I could give a better answer.
Yes no problem. But it wouldn't be an automatic process, nor a particularly simple one. All the UI elements, persistence stuff and so on (the platform specific parts of your application) will need to be redone. Depending on your app, and how it is written, this may be a major part, or a relatively small one. The more corners that were cut originally, the more it will cost to port over.
In addition to Tom's answer, I would say it has some limitations(link 1 and link 2) . I blogged some other interesting moments here.
Here is a good example of cross-platform mobile application (monoDroid, monoTouch, WP7).

Resources