Is the asp.net mvc 5 sample project with 2 factor authentication a sample or production ready? - asp.net-mvc-5

It seems like the only way I can currently get 2 factor authentication from identity 2 is if I create an empty MVC 5 app then install the Identity samples Pre release with the package manager like so:
Install-Package -Prerelease Microsoft.AspNet.Identity.Samples
But it seems like this is only a sample and not something I can use for a real app? Can I use this "sample" project as a real app? It says in the documentation at www.asp.net/identity that it is a production release!
I just want to get 2 factor authentication into a project and I'm not sure how to do it? All the guides online show the use of the prerelease sample project from NuGet. I guess the question is - is this sample project ready for the "Show" or should I wait for a project template in VS 2013 to show up in some update? I'm afraid that if I create a MVC 5 app now with no 2 factor authentication and then try and add it later it will be a pain in the ars! Or if I use the sample project with 2FA now it might have major bugs that will be a pain in the ars later to fix being that its just a sample app.
Last question! If I do end up using the sample app to create a 2FA in my app can I still register with Facebook/Google/Twitter/etc for login?

The samples are showing how you can enable 2FA and more features of Identity. They have some areas which are not production ready such as the WebAdmin scenario of managing users and roles. We are updating the project templates in next update of Visual Studio 2013 which will have 2FA enabled in the templates. The project templates are based on the samples so will be pretty close in terms of content.
You can also use Facebook/ Twitter etc for logging in in the samples package

Related

Using Azure SDK for JS to create .NET 4.x App Service

I'm starting to wonder whether this is the right tool for the job, still here goes.
I'm attempting to automate the creation of our Azure Test environment using Azure SDK for JS. The environment spans many services (as you can imagine), including Classic ASP.NET app services.
Node is my safe space, so that is why I started with the JS SDK.
I have started scripting the creation of an app service using WebSiteManagementClient.webApps.createOrUpdate. I'm confused though, there is seemingly no way to configure any of the following:
Which app service plan the app service should be connected to. This feels fundamental.
The operating system, Windows or Linux.
The stack version, .NET 4.8, .NET Core, or whatever.
Is it possible to configure the above using the JS SDK, or am I going to have find another approach?
Update 23/03/21
Untested, but these are my findings so far:
App Service Plan - The plan is set using the serverFarmId property of the Site interface.
Operating system - Assuming Windows as the default, if you want a Linux app service, you change the kind property of Site from app, to app,linux.
Stack & version - In the SiteConfig interface, you have linuxFxVersion and windowsFxVersion. Again, I think the assumption is 'latest .NET' (e.g. .NET 4.8). For .NET Core 3.1, the setting looks to be DOTNETCORE|3.1.
It can be achieved using js SDK. I checked the source code and it is ok. But I don't recommend to use js sdk to do this.
Because you need to call the SDK, there are many internal logics that you need to code. This will waste a lot of your time. So I recommend you to use restapi.
The restapi method name is similar to the naming in the SDK, mainly because you can test api interfaces online to achieve the functions you want. So you can selectively choose the method you want to achieve the function you want.
Official doc
Web Apps - Create Or Update
As for your concerns, you only need to write all the configuration in json format and put it in the request body.
Tips:
First use the online interface, encode the json format, create a webapp according to your needs, and then integrate it into your code.

How would I go about publishing Orchard.Core so I could deploy to a web host?

In Orchard 1.x, my setup was the following:
Cloned Orchard 1.x and kept it clean (unedited) and updated on my local repo.
Publish that clone of Orchard 1.x to another local repo that I would keep clean and update from the clone above as necessary.
Create multiple clones for different landlord/tenant sites of the Publish of Orchard 1.x, and set each up remotely in separate Bitbucket repositories. These would have staging/production branches.
The above is just a simplistic version of what I actually did.
With Orchard.Core, since it's currently in Beta 2 (or 3, I think), documentation is still being created. In some instances of documentation, I get the impression I can do a similar thing as the directions are to download the source and reference the appropriate NuGet packages. But I don't see much of anything specific about publish/deploy (except some information from blog posts from about a year ago - which is likely stale).
On the other hand, I see some blog posts mentioning that all you really need to do is reference the NuGet packages to run a site locally, but there is no further insight into the publish/deploy scenario. I can infer that maybe just publishing that might be sufficient, but I am not sure.
As it's still in beta, I have no intention of pushing Orchard.Core out on a live site. I just want to start preparing for when 2.0 arrives. I can test out locally whether or not what I did with Orchard 1.x will work with Orchard.Core, but I want to make sure I do it correctly. Just concerned I might be missing something.
Can anyone confirm the publish/deploy steps for Orchard.Core currently? Any insight is appreciated.
Yes, you can publish the application.
Then, if you are on Windows and want to host it on IIS, you will need install the .NET Core Framework and the ANCM (ASP.NET Core hosting module).
In IIS, create a site pointing to the publish folder, with an application pool with 'No Managed Code' for '.NET CLR version' and 'Integrated' for 'Managed Pipeline Mode'.

Azure Function Structure

I'm trying to wrap my head around how we're supposed to build Azure functions.
I love the idea of building serverless, compact, single-function apps that respond to events.
Here are the problems I'm running into:
I have nice class libraries built in .NET Standard 2 that handle all my "backend needs" namely handling CRUD ops with Cosmos Db, Azure Table Storage, Azure SQL, Redis, Azure Storage. No matter what I did, I couldn't integrate these class libraries into an Azure Functions project. More details below.
Also, getting dependency injection in Azure Functions project has proven to be quite a task -- especially with my class libraries mentioned above.
At this point, the only option I'm seeing is to "copy and paste" code into a new Azure Functions project and use it without any DI.
This seems to go against "best practices". So what's the solution other than either to create monolithic code or wait till Azure Functions support .NET Core and DI.
I thought I could use my .NET Standard class libraries from a regular Azure Functions project targeting .NET Framework. After all, the idea of .NET Standard is to "standardize" things. I opened a couple of posts here on SO. I'm providing the links so that you can see the issues I've run into:
Using .NET Core 2.0 Libraries in WebJob Targeting .NET Framework 4.7
No parameterless constructor error in WebJobs with .NET Core and Ninject
P.S. My previous posts are referring to WebJobs. That was plan B approach because WebJobs seem half a step ahead of Azure Functions when it comes to supporting things like .NET Core and DI. Ultimately, I'd like to build a few Azure Functions that can use my class libraries built in .NET Standard 2.
Also, my previous posts mention that my class libraries target .NET Core 2.0. Since then I converted them to .NET Standard 2 which didn't really take much at all. I did this so that I truly conform to .NET Standard 2.
One issue is that Visual Studio has an outdated version of the Functions Core tools. Until this is resolved, you can work around in the following way:
Install the latest via npm by running npm install -g azure-functions-core-tools
In your Function App in VS, go to the Properties
Go to Debug, and click New... under Profile
Name the new Profile something like FunctionsNpm
Set the executable to (replace [YourUserName]): C:\Users\[YourUserName]\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\func.exe
Set the arguments to host start
Set the working directory to $(TargetDir)
In toolbar, look for the green triangle icon to change your current Profile to the one you just created:
Now when you run from VS, you'll be using the npm tools instead of the older one that come with the VS package.
.NET Standard 2 support is on its way, see this github issue.

Themes in Orchard hosted in Azure

I've been setting up Orchard 1.8 in an Azure Cloud Service. I've got it working, but I'm now confused as to how to use it.
Installing themes via the gallery fails silently. The devs say this is because Orchard on Azure doesn't support the theme gallery, and suggest adding new themes to the project and uploading a new package (https://orchard.codeplex.com/discussions/453688). Ignoring that this requires any designers that want to make minor CSS changes now need Visual Studio, access to the entire source code, and then wait through a 20 minute deploy, this just doesn't seem possible.
This post explains how the Azure emulator doesn't work with Orchard. So now I'm confused; what is the expected workflow for a brand new Orchard site hosted on Azure if I can't make changes to the site in production or staging but cannot run it locally either. I'm aware I could run it without the Azure emulator on regular IIS but that seems to be too far removed from the production environment to be a good test.
I was drawn to Orchard originally because it had great documentation and supports MVC Web API, but this seems so fundamental that now I'm not so sure. I feel like every time something goes wrong they'll always be doubt whether it's working as designed or if there is an Azure idiosyncrasy going on.
I'd love to hear from anyone who's had an Orchard site from scratch in Azure, I'm hoping I've just missed something simple with this.
Thanks,
Tom
You should never install modules or themes on a production server. Instead, install those on your dev machine, build the package and then deploy. If you don't want to deal with the heaviness of cloud services, don't use cloud services. Azure Web Sites are about a million times easier to use, and they work great. They allow for what you're asking for.

How can we protect our MVC2 code?

In a normal ASP.NET Website there is a Web Deployment Project that we can use to pre-compile our entire website and then we can safely upload this project to our production server in order to protect our code.
What can we do for ASP.NET MVC 2?
Link to it as is available today (RTM version)
Visual Studio® 2010 Web Deployment Projects - RTW
Make sure you install the latest security patches for your operating system and hire a good network administrator. No kidding. No matter what you do if a hacker gains control over the server he will get the code under one form or another even if it is precompiled. This being said it is a good idea to precompile the application and deploy only the assemblies instead of the source code. You could also consider obfuscating it also but this is something usually done for client applications which you deploy to your users computers and less frequently done in server side applications because you control the server.

Resources