How to create a time limit to useWeb Api .NET Core Web API? - asp.net-core-webapi

When the time is up, the message is not allowed to access it.

Related

How to subscribe to Microsoft Graph change notifications in a separate ASP.NET endpoint using SDK

I have 2 ASP.NET Core sites:
allow multiple users to sign in to the Microsoft Identity platform then cache their tokens in SQL Server
load the tokens to subscribe and receive Microsoft Graph change notifications, e.g. subscribe to calendar event changes in the default calendar of each signed in user.
Microsoft has a sample project that sorted out my token caching/loading need: Accessing the logged-in user's token cache from background apps, APIs and services.
For Microsoft Graph change notification, there is a REST API, but I'd like to know if there is a way to subscribe in the Microsoft Graph SDK.
The sample project shows a way to use ConfidentialClientApplication to load the token, this is fine as long as I stick to the REST API by attaching the bearer token in the header. However, I'd like to use the SDK so that I don't have to recreate all the classes to deserialize the response, plus all sorts of other data I need to get from Microsoft Graph after receiving the notification.
Microsoft officially has a user-use Microsoft Graph client library for .NET (SDK), which is used to call Microsoft Graph. You can refer to this official document.
https://learn.microsoft.com/en-us/samples/microsoftgraph/aspnetcore-webhooks-sample/microsoft-graph-change-notifications-sample-for-aspnet-core/

How to access Power BI Report Server REST API

Good Day!
I am creating a sample POC in which i want to access Reports which are build in Power BI Reporting Server. I am creating this application using dotnet core.
I believe that there are rest apis to access these reports. How can i access these REST Apis or do i need to register an app for this and get the client id and client secret key?
Early response is well appreciated.
Got this after searching in internet for 2 days. Had to create an app and then token generation which was not at all necessary. Below is the simple link for accessing the power BI reporting APIs:
SSRS Swagger HUB

Application Insights tracking only failed ASP.NET MVC Web API requests

I have a ASP.NET Web API controller that provides a saveAndNew operation.
This class is derived from System.Web.Http.ApiController as expected.
Application Insights is correctly configured using version 2.1.0 of the SDK and the default settings in ApplicationInsights.config.
If a request to the mentioned operation fails - for example with status code 400 - the request is recorded correctly in App Insights.
The problem is that if the operation SUCCEEDS (status code 200) nothing is recorded in Application Insights.
I've used Fiddler to see if the request is made to the App Insights track service and it is not. So the problem is not in the configuration of Application Insights on the Azure portal.
I can't figure out what is preventing ALL requests to my Web API controllers operations from being recorded.
Can anyone help?
You might want to try removing/commenting out TransferRequestHandler in ApplicationInsights.config file.
GitHub issue "REST API app can have all requests filtered out" here states that: "commenting out the one line in the ApplicationInsights.config caused successful requests to start getting logged. Web API 2 project.
<!--<Add>System.Web.Handlers.TransferRequestHandler</Add>-->

Adding an asp.net MVC page along with Azure Mobile services

I have backend(e.g. https://api.myapp.com) based on the Azure Mobile services(AMS), now I need
1. add one or two apis that doesn't require to be on AMS e.g. an heartbeat controller to check that service is online or not, that doesn't require Zumo Auth
2. an ASP.net MVC page(e.g. https://www.myapp.com) that explains about the application
Can I use the existing AMS to do this, I tried to add plain asp.net web api, but getting error that end point doesn't exist
Are you truly using Azure Mobile Services and not Azure Mobile Apps? You generally cannot have a custom domain on Azure Mobile Services. Since you mention ZUMO Auth 2, I'm assuming you mean App Service Auth and thus Azure Mobile Apps.
I'd recommend taking a look at Azure Functions for any APIs that do not require ZUMO. However, you can just add a custom API to your service. I cover all the options for you in my book - http://aka.ms/zumobook - chapter 4.
As to a service controller for checking heartbeat. If the intent is to ensure that the service is alive, then just create an unauthenticated custom API that tests the database connectivity (maybe does an SQL command to get the count of rows in your main table) and returns success or failure. You can then use Azure Functions, Azure Scheduler or OMS to do a query of that custom API.

The best option for sending asynchronous callbacks from a Web API to a .NET client

I have the following scenario in my project :-
The client makes use of ASP.NET Web API to make HTTP service requests. The Web API sits on top of a couple of WCF services, which in-turn handle all the business logic. The client subscribes to a particular type of event with the Web API. Whenever the Web API receives notifications from the internal WCF services about the occurrence of the event, the Web API in-turn needs to notify (push events to) all the subscribed clients about the events along with their details.
I want to understand the different options which are available for
sending asynchronous callbacks from an ASP.NET Web API to the
clients.(Currently we are working on a prototype for which the
client is a C# Windows Forms application. Later we might opt for
ASP.NET MVC4 web application.).
I also want to know which option would be ideal to send asynchronous
notifications back to the client when the data that accompanies the notification is of large sizes. In our scenario, the notification data that is sent back from the service may be of large sizes (~ in the range of 5KB - 50 MB).
In our scenario which I described above, can SignalR be used for notifying the c# client from Web API, as and when the Web API receives the callback from the internal WCF services?
Note :- The Web API is currently hosted in a Windows Service and the client is a .NET Windows Forms application.
Any pointers to such code samples or directions on how this can be achieved would be extremely helpful.
Cheers
SignalR is a good fit for the scenario you're describing, so I'd suggest using it for the notifications (especially since you want to start with a WinForms application and later switch to browser clients - with SignalR, you'll be able to connect to the same server-side code).
However, I'd also suggest keeping the notication messages lightweight, so instead of sending the data to the client with them, I'd send a token the client can retrieve the data with from WebAPI (SignalR isn't really ideal for large file transfers).

Resources