I'm rather new to everything so I'm hoping this is an easy fix!
I've written an API that uses basic authentication. It works wonderfully on local host, when I try to make a GET call from my browser it will popup asking for my username/password. I enter it and it does what is should.
However, after I publish it to our server it stops working. If I do the same thing it just returns an error rather than a challenge.
Here is what it returns on the server side.
An error has occurred.
No OWIN authentication manager is associated with
the request.
System.InvalidOperationException
at
System.Web.Http.Owin.PassiveAuthenticationMessageHandler.SuppressDefaultAuthenticationChallenges(HttpRequestMessage
request) at
System.Web.Http.Owin.PassiveAuthenticationMessageHandler.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at
System.Web.Http.HttpServer.d__0.MoveNext()
I'm not sure that this is a good solution but I managed to solve the problem.
After reading this https://katanaproject.codeplex.com/discussions/531740
I added <modules runAllManagedModulesForAllRequests="true"> In the web config.
Which gave me the username/password prompt that I needed.
After fixing that I realized that having Basic Authentication turned on in the IIS settings was causing it to loop the login prompt. Once I turned it off there I had no more problems.
Hope this helps if anyone else gets in this situation.
Related
I have a Stateless Service Fabric project (.NET Core) that I need to kick off a Docker job from. I'm using Docker.DotNet and the following code works well in a small Console App, however will not work in Service Fabric:
var dockerClient = new DockerClientConfiguration(new Uri("npipe://./pipe/docker_engine")).CreateClient();
// error occurs on next line (in Service Fabric)...
dockerClient.Images
.CreateImageAsync(new ImagesCreateParameters
{
FromImage = "jbarlow83/ocrmypdf",
Tag = "latest"
},
new AuthConfig(),
new Progress<JSONMessage>());
I see this error in Service Fabric Explorer if I try to run it from the Stateless SF project:
System.UnauthorizedAccessException: Access to the path is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Pipes.NamedPipeClientStream.ConnectInternal(Int32 timeout, CancellationToken cancellationToken, Int32 startTime)
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Docker.DotNet.DockerClient.<>c__DisplayClass6_0.<<-ctor>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Net.Http.Client.ManagedHandler.d__33.MoveNext()
I'm not sure if this is actually a permission issue, or if it's related to how Service Fabric network isolation works.
I'm trying this on my local development instance, and this will eventually (hopefully) go to an on-premise setup.
Is there a way to access named pipes on the node that is hosting a SF application? Or perhaps another suggested way to run Docker through a .NET Core SF application?
Just came across this when I ran into this issue today, and ended up stumbling onto a different solution if you don't want to switch away from the Named Pipe connection. If you set up your Service Fabric service to run as a LocalSystem Account instead of the default account, it should work as well.
You can follow the instructions here to change the Account your Stateless Service runs under in the Manifest
This works because according to this article on Named Pipes, only certain types of accounts get access to the Named Pipe, one of which is LocalSystem.
I was able to get this working by changing my DockerClientConfiguration line to no longer use named pipes, and instead use http://localhost:2375:
var dockerClient = new DockerClientConfiguration(new Uri("http://localhost:2375")).CreateClient();
And then enabled Expose daemon on tcp://localhost:2375 without TLS in the Docker CE General Settings:
Im using an example from this link :
https://learn.microsoft.com/he-il/azure/storage/blobs/storage-quickstart-blobs-dotnet?toc=%2Fen-us%2Fdotnet%2Fazure%2FTOC.json&bc=%2Fen-us%2Fdotnet%2Fazure_breadcrumb%2Ftoc.json&view=azure-dotnet&tabs=windows
it works fine on local device , and i can upload a file to azure. but when i run the app on the raspberry pi , i get an error while trying to upload the file :
ex {Microsoft.WindowsAzure.Storage.StorageException: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.d__c`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at App10.MainPage.d__31.MoveNext()
Request Information
RequestID:df2e03db-101e-0128-4a45-c640d2000000
RequestDate:Sat, 16 Feb 2019 12:06:26 GMT
StatusMessage:Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
ErrorCode:AuthenticationFailed
ErrorMessage:Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:df2e03db-101e-0128-4a45-c640d2000000
Time:2019-02-16T22:14:38.5545020Z
} Microsoft.WindowsAzure.Storage.StorageException
any ideas?
I think that the problem is the authentication, in the original article Microsoft tell you to call setx storageconnectionstring "<yourconnectionstring>", have you made it on raspberry?
The sample works for me with following steps.
Replace the variable storageConnectionString with the connection string of my storage.
Run command dotnet publish -r win10-arm to publish the app for windows iot core.
Copy the folder storage-blobs-dotnet-quickstart\bin\Debug\netcoreapp2.0\win10-arm\publish to the device.
Run the storage-blobs-dotnet-quickstart.exe via powershell connected with device.
It would works fine. Please try again. If the error appears again, feel free let me know.
I have solved my problem.
both of you are right. because the time was not set right azure reject the request. after setting the time the RP have managed to send the data to blob. tnx !
I have a Windows 8.1 app on the Store, but when I try to use the next piece of code for a new feature I want to add to my app
var listingInfo = await CurrentApp.LoadListingInformationAsync();
I receive an error which I don't exactly know what it means. I did catch the error though and I displayed it on a MessageDialog and then I took a print screen. This is the error:
We could not receive your donation due to an unexpected error:
System.Exception: Exception from HRESULT: 0x801900CC
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at ArchMedia_Player.Services.Donations.<ListingInformationAsync> d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at ArchMedia_Player.Services.Donations.<Donate>d__a.MoveNext()
Does anybody know what that means and how can I solve it ?
I also mention that this works perfectly ok: (using the CurrentApp Simulator)
var listingInfo = await CurrentAppSimulator.LoadListingInformationAsync();
System.Exception: Exception from HRESULT: 0x801900CC
That's an expected exception while you are developing your app. The error code is BG_E_HTTP_ERROR_204, 0xCC encodes the HTTP response error code. 0xCC == 204, HTTP error 204 means "No content". Or in other words, the Store server is not aware of your app having any in-app purchases.
This is a chicken-and-egg problem, the server doesn't know about your in-app purchases until after you submitted your app and got it approved. You must test your app with CurrentAppSimuator to debug and test your in-app purchases. The basic how-to guide is here. One important step you must not forget is to substitute CurrentAppSimulator with CurrentApp just before you submit your app for verification.
That your app is already in the Store does not factor in when you added in-app purchases to your new version. The crucial required step is to make the Store server aware of your purchase options. As described by the linked MSDN article, you do this when you submit the app. They will not be effective until your submission is approved.
So, do not panic, you can test your code with the simulator. When you've verified that you got that working, there's little reason to fear this being a problem after you submitted the app, as long as you follow the steps in the MSDN article.
I had same exception. I updated package certificate File (StoreKey.pfx), by creating package with sign in to the windows store. And it fix problem for me.
I'm getting this exception when awaiting LoginAsync:
await fb.LoginAsync("user_about_me");
The full stack trace is the following:
{System.InvalidOperationException: Operation is not valid due to the current state of the object.
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at FacebookServiceClient.FbServiceClient.<Login>d__0.MoveNext()}
I'm using Facebook Client 0.5.0.
The strange thing is that this error doesn't always occur, usually when I start a coding session everything is just fine, but then (after a few debug sessions) this exception popups every time.
Any thoughts?
Edit: I have this problem even on the SDK github sample
The problem is not anything to do with the operation itself after browsing the code I found out that the problem is when the browser fails to connect to facebook this exception is thrown.
I'm using Silverlight 4.0, and am trying to get a request trough https. All I get is the exception below, which is not really helpful, because no search engine finds any related solution...
request = WebRequest.Create( new Uri("https://myurl.com/myfile" ) );
asyncResult = request.BeginGetResponse();
...
request.EndGetResponse( asyncResult );
{System.ArgumentNullException ---> System.ArgumentNullException: Value cannot be null.
Parameter name: s
at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
--- End of inner exception stack trace ---
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
It works when I use http instead of https. It works when I use the browser via https. But not like this. Any hints where to look for an answer, or even an answer would be very much appreciated.
[EDIT]
Ok, I found out what seems to be the problem: apparently it has something to do with Firefox and certificates. When I run the xap in IE, it asks me to trust a certificate, and then it works. In Firefox I never get such a question, and it never works (even though I downloaded the xap over that very address.) So now the question is: How do I get working https, Firefox and Silverlight to work together?
[EDIT2]
I'm still on the same problem, but there is something more to it. Not only Firefox has the problem, but also out-of-browser (even if installed from IE). There is someone with a similar exception, but no answer: http://forums.silverlight.net/forums/p/210114/494451.aspx
Got it.
The problem was that the Root CA Certificate of the Server was untrusted. Because I had IE 6 installed, I did not really see the message. The exception added to Firefox did not propagate to Silverlight (because Silverlight apparently always the Global Windows Certificates).
Installing IE 8 reveals that the Root CA Certificate was untrusted right beside the address bar. Click that message, add the Root CA Certificate to the ones used by Windows and voilĂ , everything works, IE, OOB and Firefox.