How use MSAL.NET on .NET6 Application - c#

I run Windows Form Application on .NET 6 using Microsoft.Identity.Client and PublicClientAppBuilder, but when clicked to log on ... pops up that message ...
If runs the same code on Windows Forms from .NET Framework 4.6.1 it works perfectly, but not on .NET 6.
The MSAL.NET not have support for .NET 6? or need make somes adaption to the code?
Solve that problem ... or finds alternatives solution ...

The pop up message clearly says that, the given redirecturi is not supported for the current version.
In Azure Active Directory, add the RedirectURI as http://localhost.
Also in Program.cs change the WithRedirectUri as below.
WithRedirectUri("http://localhost")
Same is mentioned in the MSDoc, The RedirectURI for .NET Core has to be https://localhost. The error/alert says the same.
The MSAL.NET not have support for .NET 6? or need make somes adaption to the code?
Even I do not find any official document or any code samples which explains the .NET 6 version.

Related

.Net Core 3.0 Angular SSR Project not running

I have a .net core 3.0 project with an angular 8 frontend that uses webpack.
I need to enable server side rendering on the angular project for SEO and other indexing reasons but I am not able to get the project to run with server side rendering enabled.
I encounter various errors, see below. But ultimately it would be good if someone could point me in the right direction or let me know if SSR is achievable in .net core 3.0, if not then I can use 2.2 if it means SSR will work.
I have actually been able to get a .net core 2.2 angular SSR project to work but as soon as I do a HTTO get on anything other than the index page through postman, it returns 404 "Cannot get".
Here is the .Net Core 2.2 project I have been able to make work.
Here is one of the tutorials I have followed which uses .Net Core 2.2.
Also, it seems that app.UseSpaPrerendering is now deprecated in .Net Core 3.0, and I cannot find any documentation on how to make SSR work without it.
Here is the main error I encounter when trying to run the test project which I followed the above tutorial to build:
NodeInvocationException: Prerendering failed because of error: Error: The module at main.js does not export a default function, and you have not specified which export to invoke.
There seems to be very little documentation on .net core + angular SSR so any advice would be appreciated.
I followed this article's instructions and it works like a charm for netcore 3.1. It also mentions your NodeInvocationException. According to the author this happens, "when your app starts to run before the Angular CLI server has finished building the app server-side".
It works despite the deprecation warning that you will get for UseSpaPrerendering().
PS: I had also to set the build action for main.server.ts and main.ts. Maybe the author just forgot to mention it.

azure mobile service not working on xamarin.android

I'm trying to implement Azure Mobile Services in my Xamarin.Forms app.
I'm following this link and it works on iOS but not on Android.
It throws this exception:
MobileServiceInvalidOperationException - "The server did not provide a response with the expected content."
I have tried switching between HTTP and HTTPS but could not get it working.
It works on Android (native) as well, just not on Xamarin.Android
Any help?
Your issue is tracked here, and seems to be because of the following:
we don't support .Net Core 2.1 in the SDK today. Unfortunately, we don't have a workaround today and like Ela said, the we don't have an ETA for a new release or other SDK to use for .Net Core 2.1 compatibility yet, so your only workaround is to stick with .Net Core 2.0 for now.
There seems to be a temporary work around here, by brendanzagaeski to in the call to new MobileServiceClient():
Either pass in an HttpClientHandler instance
Or pass in an instance of AndroidClientHandler
It seems like AndroidClientHandler is the one that works the most often.
Check if "microsoft.azure.mobile.client" is referenced on your project. If not, try installing a lower version of the "microsoft.azure.mobile.client" through nuget package on your project add the using directive and then update the "microsoft.azure.mobile.client" through nuget package.
And update any pending package.

Combine ASP.NET and ASP.NET core in the same solution

I am creating a solution using ASP.NET Core 1.1 (SDK 1.0.4) and I require to use System.DirectoryServices namespace.
According to this Github issue
they are porting those APIs from the .Net Framework in the upcoming 1.2 version. However, I have seen that you can create an ASP.NET Core app targeting the full .Net Framework. I have follow some tutorials but all of them seem to be outdated (.Net Core 1.0 using project.json) and I have found no way to make it work.
In the same manner, I have seen some Github projects that seem to run ASP.NET Core and System.DirectoryServices namespace using something called DNX (like this one ). However, this project also fails in Visual Studio 2017.
Is there any real solution to have access to System.DirectoryServices on ASP.NET Core?
There might be a hacky way to go about it, but I haven't explored this enough, yet. I have noticed that when you create an "ASP.NET Core Web Application (.NET Core)" project, it doesn't allow you to change the .NET framework version to anything but available .NET Core versions. You'll need to create an "ASP.NET Core Web Application (.NET Framework)" project in order to use the full framework.
If you've already got an existing project you're working on, the best thing I can recommend is to simply create a new "ASP.NET Core Web Application (.NET Framework)" project and migrate your existing code over to that. For the most part, it should just be copy-and-paste. Like I said, there might be some other way, that I just don't know, but you at least have that method.
FWIW, DNX was .NET Core, before it was ".NET Core". There was a somewhat similar setup where you could run DNX on full .NET or just the "core" .NET functionality. It doesn't really help you here.

Enable / Install .net 4.5 on IIS?

I'm pretty new to using C# and IIS and have been having a hard time getting my .net updated to 4.5. My application as of right now is just a single handler page with no solution hosted on a url controlled by Iis. The current version my IIS is running for that application pool is v4.0. I want to enable v4.5 but don't know where to start. I've been searching google for the past few hours now but none of it makes any sense to me.
.Net 4.5 still uses the 4.0 CLR and that's what you're picking. You won't see an option for 4.5 here. Just ensure whatever version you want is installed and compile your application against the newer .Net versions (which go up to 4.6.2 right now) and it will be just fine.
To learn more about the difference check out this blog post: https://blogs.msdn.microsoft.com/karinm/2008/11/10/whats-the-difference-between-clr-and-net-framework/
In the above screen shot click on the "application pool" and check the framework version you application is running on you can double click and change as appropriate.
Try following what's in the link. It should work :)
https://technet.microsoft.com/en-us/library/hh831475(v=ws.11).aspx
Note: you can use any .Net 45 application with v4.0 app pool

Is there a Facebook SDK for .NET that works with 3.5?

When I first created my site, there were no .NET SDKs for Facebook so I wrote my own. It was pretty hacky, but it worked. Due to various Facebook changes, it's now broken beyond repair so I figured I'd use a real library. The one I found was the Facebook C# SDK.
However, it seems you can only download the source and compile it, and it seems it requires .NET 4.0 to compile. Also, looking through the code it seems to use .NET features such as System.Threading.Tasks. I'm still on .NET 3.5 and cannot upgrade at the moment. I'm wondering if there's a) a way to make this project work on 3.5, or b) another library that would be better in my case.
Facebook C# SDK supports .net 3.5sp1.
You can download using nuget.
If you are using VS 2008 where nuget package manager is not support, you can download using nuget command line tool. (http://nuget.codeplex.com/releases)
nuget install Facebook
For pre-release version you can download using the following command.
nuget install Facebook -pre
I have websites in .Net 3.5 using the latest code from the Facebook C# SDK. However, here's what I do. I use the "client" Facebook.dll to do all the stuff. Yeah, I don't get some of the wizbang session information, etc. But I do get full access to the API. I use javascript for authentication then AJAX the access token to the server.
I guess it depends on how committed to making the new SDK work with your codebase.
You could branch the code from Facebook C# SDK as you listed and replace all the task stuff with System.Threading.Threads, but that could result in a lot of work if there is extensive use of Tasks.
Or you could update your SDK to just address the areas you currently require until you can move to .NET 4. At least that way your project won't need reworking, just your internal library that your project is already referencing.

Categories

Resources