Problem: Trouble with updating a row from the mobile client (with offline sync).
Scenario: We're using a Class in the mobile client to save new items. But we're using a ClassDto when retrieving data from the server. Because of this setup, the server backend has two table controllers: ClassController:TableController<Class> and ClassDtoController:TableController<Class>. The former is used for the PostClass requests and the latter is used for the GetAllClass requests.
On the client side, the mobile database stores the rows for viewing in the ClassDto local table and only the saved entries using the mobile device are in the Class local table (i.e. ClassDto entries count != Class entries count).
Problem Detail: We need the capability to edit a Class using the device. We implemented this by copying all the (edited and unedited) details of the target ClassDto (e.g. id, version, updated at, created at etc) into a new instance of Class then used UpdateAsync on the IMobileServicesSyncTable.
From the logs in the ClassController:TableController<Class>, the request goes to this table but an error occurs.
Used a try-catch to expose the exception and this is what we got:
Message: "Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details."
Stack Trace:
at Microsoft.Azure.Mobile.Server.Tables.EntityUtils.<SubmitChangesAsync>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 Microsoft.Azure.Mobile.Server.EntityDomainManager`1.<UpdateAsync>d__10.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 Microsoft.Azure.Mobile.Server.EntityDomainManager`1.<UpdateAsync>d__3.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 Microsoft.Azure.Mobile.Server.TableController`1.<PatchAsync>d__12.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 SynthesisServer.Controllers.SaleController.<PatchSale>d__3.MoveNext()
Used PostMan to do a patch and got this message:
{
"message": "An error has occurred."
}
Question: How do we implement the editing function? Also, is it possible to use only one Table Controller for both saving and retrieving entries? We used two controllers cos can't do joins in the mobile client. We tried returning a ClassDto from the ClassController but that resulted to an error. We also tried pushing a ClassDto to the ClassController but that again resulted to an error.
Related
I'm trying to run a console application as a windows service which communicates with outlook exchange online using EWS. This has OAuth authentication and for that AppID is registered on the Azure portal. I am able to generate access token and communicate with exchange online successfully.
However when run from a remote server, it gives request timeout error. Request to the endpoint to get access token is timing out.
Can you please help me with this. I'm not able to identify the issue.
Below the access code:
var cca = ConfidentialClientApplicationBuilder
.Create(ConfigurationSettings.AppSettings["appId"])
.WithClientSecret(ConfigurationSettings.AppSettings["clientSecret"])
.WithTenantId(ConfigurationSettings.AppSettings["tenantId"])
.Build();
var ewsScopes = new string[] { ConfigurationSettings.AppSettings["EWSScope"] };
var accessTokenRequest = cca.AcquireTokenForClient(ewsScopes);
var accessToken = accessTokenRequest.ExecuteAsync().Result.AccessToken;
Below error
System.AggregateException: One or more errors occurred. ---> Microsoft.Identity.Client.MsalServiceException: Request to the endpoint timed out. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled. at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Identity.Client.Http.HttpManager.<ExecuteAsync>d__14.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Identity.Client.Http.HttpManager.<ExecuteWithRetryAsync>d__12.MoveNext() --- End of inner exception stack trace --- at Microsoft.Identity.Client.Internal.Requests.RequestBase.<HandleTokenRefreshErrorAsync>d__27.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.Identity.Client.Internal.Requests.ClientCredentialRequest.<ExecuteAsync>d__2.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.Identity.Client.Internal.Requests.RequestBase.<RunAsync>d__12.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.Identity.Client.ApiConfig.Executors.ConfidentialClientExecutor.<ExecuteAsync>d__3.MoveNext() --- End of inner exception stack trace ---
Does the remote server have access to the authentication endpoint eg login.microsoftonline.com. Is there any proxying being used ? you could try running the ewseditor from that remote server https://github.com/dseph/EwsEditor/releases to see if you can authenticate using oAuth
We're running an ASP.NET MVC Core 1.1 application on a web farm with 2 servers and ran into these exceptions, when a user is attempting to upload a file. We believe this is happening because the get request is from one server and their post may be going to the other web server, leading to the keys being not matched?
Is there a way to get around this issue?
Error 1:
The antiforgery token could not be decrypted.
at Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgeryTokenSerializer.Deserialize(String
serializedToken) at
Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery.DeserializeTokens(HttpContext
httpContext, AntiforgeryTokenSet antiforgeryTokenSet,
AntiforgeryToken& cookieToken, AntiforgeryToken& requestToken) at
Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery.ValidateTokens(HttpContext
httpContext, AntiforgeryTokenSet antiforgeryTokenSet) at
Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery.d__9.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.AspNetCore.Mvc.ViewFeatures.Internal.ValidateAntiforgeryTokenAuthorizationFilter.d__3.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.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__20.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.AspNetCore.Builder.RouterMiddleware.d__4.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.AspNetCore.HttpOverrides.HttpMethodOverrideMiddleware.d__4.MoveNext()
--- End of stack trace from previous location where exce
Error 2: The antiforgery token could not be decrypted.
at
Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgeryTokenSerializer.Deserialize(String
serializedToken) at
Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery.DeserializeTokens(HttpContext
httpContext, AntiforgeryTokenSet antiforgeryTokenSet,
AntiforgeryToken& cookieToken, AntiforgeryToken& requestToken) at
Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery.ValidateTokens(HttpContext
httpContext, AntiforgeryTokenSet antiforgeryTokenSet) at
Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery.d__9.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.AspNetCore.Mvc.ViewFeatures.Internal.ValidateAntiforgeryTokenAuthorizationFilter.d__3.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.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__20.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.AspNetCore.Builder.RouterMiddleware.d__4.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.AspNetCore.HttpOverrides.HttpMethodOverrideMiddleware.d__4.MoveNext()
--- End of stack trace from previous location where exce
Do you have a machine key defined (see this: Adding machineKey to web.config on web-farm sites)? Both servers should have the same machineKey config entry (can be generated within IIS or via online tools).
<machineKey
validationKey="GENERATED VALUE"
decryptionKey="GENERATED VALUE"
validation="SHA1"
decryption="AES" />
For DotNetCore Apps running on IIS, if your application pool is set to use AppPoolIdentity, then you need to make sure "Load User Profile" is set to "True" in the Application Pool Advanced Settings.
See: https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/default-settings?view=aspnetcore-2.1
If the user profile is available, keys are persisted to the %LOCALAPPDATA%\ASP.NET\DataProtection-Keys folder. If the operating
system is Windows, the keys are encrypted at rest using DPAPI.
I am building a native application that uses Microsoft Graph.
I want to read all the files in OneDrive of all the users in the organization, via admin account.
I am using the (Azure AD 2.0) OAUTH authorization workflow to get the authorization code. After which I get the access token and refresh token.
However when I try to access the drive of any user :
graphClient.Drives["amit#csys.onmicrosoft.com"].Root.Request().GetAsync();
// where graphClient is instance of GraphServiceClient
I get:
generalException
Message: Unexpected exception returned from the service.
With call stack :
at Microsoft.Graph.HttpProvider.<SendAsync>d__19.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.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Graph.BaseRequest.<SendRequestAsync>d__34.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.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Graph.BaseRequest.<SendAsync>d__32`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.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Graph.DriveItemRequest.<GetAsync>d__6.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 OneDrive_Writer.OneDriveWriter.<loadRootDriveFolder>d__9d.MoveNext()
Is there a way an admin can access all other users drives files?
NOTE: I am able to access the Admin's OneDrive account when I login as Admin.
The Drives indexer in your example expects a driveId, not a upn.
Assuming that your permissions are properly set, and you have a valid access token,
you'll do something like this.
// Access the users in the org.
var users = await graphClient.Users.Request().GetAsync();
// Get the drives for a user.
var drives = await graphClient.Users[users[0].Id].Drives.Request().GetAsync();
// Get the specific drive metadata for a user
var drive = await graphClient.Drives[drives[0].Id].Request().GetASync();
first time caller here...
I'm writing a WebAPI application that connects to an Oracle database using Oracle.ManagedDataAccess. I'm using EF6 and I'm intermittently getting
"Unexpected connection state. When using a wrapping provider ensure that the StateChange event is implemented on the wrapped DbConnection."
I'm using Autofac and have everything registered as "InstancePerDependency" (also tried InstancePerRequest) so I should be getting a new instance each request but it seems as soon as my connection gets into this state it can't recover.
I've tried turning connection pooling off and also calling Dispose() on my connection.
Does anyone know what the reason is behind this behavior or give some additional details on what this exception means as Oracle.ManagedDataAccess.Client.OracleConnection appears to implement the StateChange event.
Thanks!
Here's the stack trace:
at System.Data.Entity.Core.Objects.ObjectContext.EnsureContextIsEnlistedInCurrentTransaction[T](Transaction currentTransaction, Func1 openConnection, T defaultValue)
at System.Data.Entity.Core.Objects.ObjectContext.<EnsureConnectionAsync>d__9.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.Data.Entity.Core.Objects.ObjectContext.<ExecuteInTransactionAsync>d__3d1.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.Data.Entity.Utilities.TaskExtensions.CultureAwaiter1.GetResult()
at System.Data.Entity.Core.Objects.ObjectQuery1.d__e.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.Data.Entity.Utilities.TaskExtensions.CultureAwaiter1.GetResult()
at System.Data.Entity.Internal.LazyAsyncEnumerator1.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.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.d__25`1.MoveNext()
This is a copy paste from my original posted github issue
I'm working on a prototype application leveraging the Microsoft.Graph SDK. I noticed that if I run the following code on my "Live" / Personal OneDrive account it works just fine and returns the files I expect. However, if I run the same code against my OneDrive for Business, it throws an internal exception within Microsoft.Graph.Core. I suspect the reason is that my search Url contains a * as mentioned in the error, but why does it work when searching a Live account and break when searching a Work account?
Sample Code Snippet:
var graphserviceClient = new GraphServiceClient(
new DelegateAuthenticationProvider(
(requestMessage) =>
{
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", ADALAuth.CurrentAccessToken);
return Task.FromResult(0);
}));
var drive = graphserviceClient.Me.Drive.Request().GetAsync().Result;
var collection = graphserviceClient.Me.Drive.Search("*.xyz").Request().GetAsync().GetAwaiter().GetResult();
The error message returned is:
Code: UnknownError
Message: A potentially dangerous Request.Path value was detected from the client (*).
Inner error
Stack Trace:
at Microsoft.Graph.HttpProvider.<SendAsync>d__19.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 Microsoft.Graph.BaseRequest.<SendRequestAsync>d__36.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 Microsoft.Graph.BaseRequest.<SendAsync>d__32`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 Microsoft.Graph.DriveSearchRequest.<GetAsync>d__2.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 _Default.Page_Load(Object sender, EventArgs e) in e:\Profile\Documents\Visual Studio 2015\WebSites\AzureWebApp\Default.aspx.cs:line 33
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Behind the scenes, Graph is routing your request to two different systems depending on your account type. Because of these, there are some subtle differences between the two systems.
Regardless, you shouldn't need the * as Search is already searching for the string you passed within other strings. In other words both *.xyz and .xyz get translated into *.xyz*. It will match this query in this way across several fields including filename, metadata, and file content.