Can I use mini profiler for ASP.NET Web API and have results still seen on URL? - mvc-mini-profiler

I am hitting an ASP.NET web api controller from a rest client, and I am not able to view the stats of this call in the Mini Profiler URL: /mini-profiler-resources/results. Is this not possible?

Related

Why is CORS allowed when calling to dummy API?

When I created a WebAPI project, and then a MVC project. In MVC project, I run a sever https://localhost:44303/ which has a page. In this page I created a button for ajax call. I call to my WebAPI project https://localhost:44369/ (different origin), and of course I get CORS policy. I cannot get any data. But when I change the ajax call to a fake API like on the internet https://jsonplaceholder.typicode.com/todos/1, I can get data. I think the fake API and the MVC project have different origin, so CORS should prevent the ajax call. Why can I still get the data from that fake API?
They are simply accepting request from all ip

asp.net Web Api saving user information in session context

I'm trying to create an asp.net web api that calls an external api and gets a response that needs to be stored server side in session context and then later reused in further calls.
What will be best practice for this?

Check for Anti-forgery Asp.Net MVC Core 2.0 Web Api on Fiddler

My application using Asp.Net Web Core 2.0 Web Api and Front UI in angular4. Would like to check Antiforgery before I submit my API to Angular4 developer. I am using fiddler to test all my APIs.
Gone through this topic:
Angular2 ASP.NET Core AntiForgeryToken
and applied the same, but don't know how to test it from Fiddler. I think the implementation is based on Cookie whereas to check in Http, I will need it as Http Header.
And the point is how will I get the token then.

Using Azure AD token in AJAX call from MVC application to separate WebAPI application

I have created a Azure AD protected .Net Core 2.0 WebAPI that has its own URL, and using same clientID, tenantID and domain I am able to send AJAX call from a SPA using ADAL JS.
Now, I need to implement the same without the use of ADAL JS in a MVC application. The issue I am facing is that the token generated by OIDC is not getting authorized on the separate API app.
Any suggestions for this scenario?

Repeating logic in each ASP.NET Web API request, where should that go?

I need to store some information in session(or in whatever in ASP.NET Web API) that I need to retrieve in each API request. We will have one api IIS web site and multiple web site binding will be added through host header. When any request comes in for example, api.xyz.com, host header will be checked and store that website information in session that will be used in each subsequent api request when making a call to database. Hope this is clear.
I found a way to handle session in ASP.NET Web API. ASP.NET Web API session or something?.
I know lot more about asp.net web forms where we can override PreRequestHandler. I am looking for similar in ASP.NET Web API where I can have my logic to get database id for api domain(for example, api.xyz.com) and store it in session which I want to access in each API GET/POST request.
Somebody will definitely say by adding session I am making it stateful but REST is stateless. But I wanted to save database trip for each api request. If I don't use session or something similar, I end up repeating the same logic for each api request.
Is there a better way to handle this situation? how?
thanks.
If that logic needs to happen for all requests, you better use an Implementation of delegating handlers.

Resources