I'm doing an application in UWP and since I'm managing a connection to a service in Azure that points to a database ... but I have this problem that saves me a previous error:
Clear API errors [UWP]
So it occurred to me that maybe that error is being stored in the service cache. and I do not know, is it possible to clean the cache of a service? or clean the cache somewhere in the controller so that this error is not stored.
I have looked at this documentation but I still do not know how to implement it
https://learn.microsoft.com/en-us/dotnet/api/system.web.caching.cache.remove?view=netframework-4.7.2
https://msdn.microsoft.com/en-us/library/edfcywt6.aspx
How can I programmatically clear cache?
https://www.codeproject.com/Questions/302329/How-to-force-clear-cache-in-asp-net
As #Martin Zikmund said, you'd better manage the outputcache in server side. If you want turn off the cache of httpclient, you could try this.
var RootFilter = new HttpBaseProtocolFilter();
RootFilter.CacheControl.ReadBehavior = HttpCacheReadBehavior.MostRecent;
RootFilter.CacheControl.WriteBehavior = HttpCacheWriteBehavior.NoCache;
var HttpClient = new HttpClient(RootFilter);
Related
I have an Asp.Net webpage written in c#. This webpage is communicating with a host on a server. The server adress is actually hardcoded in my controller methods as
static PatientController()
{
//Create the HttpClient once and use it
_httpClient = new HttpClient();
_httpClient.BaseAddress = new Uri("http://localhost:9002/prom2etheus/v1/");
_patientList = new List<Patient>();
}
How can I configure the URI as a parameter, that a user can enter at the start of the UI? My problem is, that the host is running on a server, and my UI is running on the same server, but in a Docker container. So the IP of the host can change, and I don't want to hardcode the IP of the host in my controller method. Which is the better way to do?
It depends. If you want the url to persist, then storing it in a database or a file is a good idea.
On the other hand, if it is okay to propt user every time the app starts, it could be stored in memory. This would jave the added benefit that, it would be much faster to read/write since there's no IO. There could be othet storage options such as third party storage provides too. In both cases, you would have to think about thread safety.
As part of a Microservice based solution that we are building we have a number of Azure Functions sitting in one Azure Function App. The functions Orchestrate numerous requests to different APIs some of which take a long time to complete. We added Application Insights to the functions to allow for some tracking of the requests made, but dependency tracking is not working yet in Azure Functions. It is possible to manually track dependencies but that involves inserting some tracking code around each dependency call, however we want to avoid manually tracking dependencies on each and every call.
One of the solutions I have thought of would be to create a request tracker that tracks all outgoing web requests from the functions. Within the request tracker I could then track the dependency requests including their time. I want to hook the request tracker into some sort of web traffic handler, unfortunately I was unable to find much about doing this. A lot of posts mention using System.Net trace writer for this, but as far as I can see this requires a Web.config to setup and functions do not have one.
I have seen a few posts mentioning to create a request wrapper and place that on my outgoing requests, but unfortantely that is not an option as we use a number of packages that make requests internally. If you have any ideas that could get me going in the right direction please let me know. Thanks
Update:
I added the following helper method which allows me to manually track tasks as dependency requests
public static async Task<T> TrackDependency<T>(this Task<T> task, string dependecyName, string callName, string operationId)
{
var telemtryClient = new TelemetryClient();
var startTime = DateTime.UtcNow;
var timer = System.Diagnostics.Stopwatch.StartNew();
var success = true;
T result = default(T);
try
{
result = await task;
}
catch (Exception)
{
success = false;
}
finally
{
timer.Stop();
var dependencyTelemetry = new DependencyTelemetry(dependecyName, callName, startTime, timer.Elapsed, success);
dependencyTelemetry.Context.Operation.Id = operationId;
telemtryClient.Track(dependencyTelemetry);
}
return result;
}
It can then be used as follows:
client.Accounts.UpdateWithHttpMessagesAsync(accountId, account).TrackDependency("Accounts", "UpdateAccounts", requestContextProvider.CorrelationId);
I can now see individual request dependencies in Application Insights, but obviously the actual telemetry on them is very limited, it does not contain path info or much else.
So when you say dependency tracking is not working in Azure Functions, what exactly do you mean? Have you actually added and configured the Application Insights SDK to your actual function yet? The out-of-the-box monitoring experience with Azure Functions doesn't automatically add dependency tracing, but if you actually add/configure the Application Insights SDK in your function project it should start tracking everything going on in there.
I've been writing a custom TFS 2013 server plugin for my company that automatically creates tasks whenever a new bug or product backlog item is created. While debugging I can see it detecting the new work item, but when it tries connect to the TfsTeamProjectCollection it throws TF30063 exception saying I'm not allowed to access the server. What baffles me is, in an attempt to see if the code after that worked, I made a simple client-side form application with the exact same code to connect to the server and it worked flawlessly.
The code I'm using to connect with is:
string tfsUri = string.Empty;
tfsUri = #"http://companytfsserver:8080/tfs/defaultcollection";
TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsUri));
tfs.EnsureAuthenticated();
I've also tried manually setting the credentials, but no luck. Also, if it helps, I used this as my guide: http://geekswithblogs.net/BobHardister/archive/2012/10/08/automatically-create-bug-resolution-task-using-the-tfs-2010-api.aspx
I read through a ton of documentation of people getting the same exception, but none of what I found seemed relevant to this particular situation, so any help would be greatly appreciated!
*Update: After more digging and testing, it's possible it may have something to do with our application tier. I'll have to wait for the IT guy that's familiar with that particular system to get back from a conference (Monday, I think), but I'll update once I find out for sure.
**Update: I finally figured it out and I can't believe how simple it was. It turns out the URI that's used to connect via client app does not work when it's used in an app tier server plugin. Instead, it has to be localhost:8080/tfs/defaultcollection. Makes perfect sense to me now, but it never even crossed my mind before.
Just as jessehouwing says, since you are using collection uri "http://companytfsserver:8080/tfs/defaultcollection" You must have permissions on the Prioject(collection) with your account and TFS service account.
// Connect to TFS Work Item Store
ICredentials networkCredential = new NetworkCredential(tfsUsername, tfsPassword, domain);
Uri tfsUri = new Uri(#"http://my-server:8080/tfs/DefaultCollection");
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(tfsUri, networkCredential);
WorkItemStore witStore = new WorkItemStore(tfs);
I stumbled upon MantisBT recently and got it set up at my workplace for future bug tracking. I wanted to make a neat little library we can use in our applications so that users can report bugs to us directly from the application in question.
Currently in a sandbox application I made to try and understand MantisConnect. I consumed the webservice successfully and I can make a client. But if I try and do this:
MantisConnectPortTypeClient client = new MantisConnectPortTypeClient();
UserData usrData = client.mc_login("omitted", "omitted");
I get a FaultException and the message "Access Denied"
Currently running Mantis 1.3.rc-dev.02
Any ideas on why this simple call is denied? It doesn't matter what user I use. It gets denied regardless.
Okay I figured it out.
The WSDL file on the server was still pointing to mantisbt.org instead of our local server. Changed it to our local server address and it worked fine.
Getting the following error while trying to access an AppFabric cache. Our Cache was created yesterday and nothing happened, that we know of, to remove the Cache. Does anybody have any suggestions on troubleshooting what could be causing our Cache to be removed from the server?
I was able to resolve the error by simply running New-Cache EAI at the PowerShell command prompt
ErrorCode:SubStatus:Cache referred to does not exist. Contact administrator or use the Cache administration tool to create a Cache.
var cache = new DataCacheFactory().GetCache("EAI");
FYI: We are using SQL for our config store