I am trying to load the exceptions to a field "Exception_type" so that I can show it on my application. I have a regex which is but giving me multpile match group.What I need is the complete message on the field "Exception_type".Apprecite if you can help.
Regex :
(?<Exception_type>[a-zA-Z]+.*[^,]*[^ ,][^,]*$)
Message:
2016-12-22 14:06:00.4563 System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:30030
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at Vinod.MyPos.MyProject.MySubProject.Vendor.Communicator.VendorSaleRequestHandler.<Send>d__13.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 Vinod.MyPos.MyProject.MySubProject.Vendor.Communicator.VendorSaleRequestHandler.<Handle>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 Vinod.MyPos.MyProject.MySubProject.Vendor.Communicator.VendorServiceCommunicator.<Send>d__4.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 Vinod.MyPos.MyProject.MySubProject.Logging.LoggingMySubProjectChildMessageProcessor.<ProcessMessage>d__4.MoveNext() MySubProject ProcessMessage Exception : client token : [c7b9396d-b790-43f5-9561-f01c6dcdddce]
You may use
(?s)^\S+\s+\S+\s+(?<Exception_type>.*$)
See the regex demo
The ^\S+\s+\S+\s+ matches the first 2 non-whitespace chunks of text separated with 1+ whitespaces and the rest is captured into Group 1.
To remove the GUID, you will need to use a second step:
\b[a-fA-F0-9]{8}(?:-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}\b
See the regex demo, replace with an empty string.
Here, \b are word boundaries and [a-fA-F0-9] matches a hex char.
Related
I have created New (as well as) extended End Point for Bill Of Materials screen/module. I want the endpoint to return a single BOMID details , while it is returning all the BOMID with details (when passed without $filter tag of it). When I have included $filter tag as specified in the Integration Document (Acumatica ERP_Integration Guide document) it returns error.
The POSTMAN URL is like ({AcumaticaBaseURL} + "/entity/" + {EndPointName} + "/" + {EndPointVersion} + "/" + {EntityName} + "/" $filter=BOMID eq '{valueofBomID}') which is as follows :
http://localhost/AcumaticaMfg21R2/entity/BOMEP/17.200.001/BOMEntity/$filter=BOMID eq '{valueofBomID}'
I have also tried passing the individual BOMID with the Body parameter in request as JSON, but that also is returning all the BOM details (without $filter tag).
Without the $filter it returns all the BOMID's present in the system; with $filter it returns an error.
Error Message included below:
{
"message": "An error has occurred.",
"exceptionMessage": "Operation is not valid due to the current state of the object.",
"exceptionType": "System.InvalidOperationException",
"stackTrace": " at PX.Api.ContractBased.EntityService.FillEntityImplWithKeys(String version, String name, EntityImpl entity, String[] keys)\r\n at PX.Api.ContractBased.SystemContracts.V2.SoapFacade.PX.Api.ContractBased.IRestGate.FillEntityImplWithKeys(EntityImpl entity, String[] keys)\r\n at PX.Api.ContractBased.SystemContracts.V2.RestController.CreateEntityFromKeys(String objectName, String idsString)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.b__2(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Filters.ActionFilterAttribute.d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ExceptionFilterResult.d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Controllers.ExceptionFilterResult.d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__15.MoveNext()"
}
I've tried the same with 18.200.001 version endpoint. Its working fine. Can you please try with 18.200.001 or 20.200.001 endpoint version?
please find the below screenshots.
Endpoint: /entity/Test/18.200.001/BillOfMaterials/?$filter=BOMID eq 'BOM000001'
I tried to update the latest version of power bi bu it won't work for me. I worked hours upon hours on a file and it won't open. please help.
Pleae find the attached error below for refernce :-
Feedback Type:
Frown (Error)
Error Message:
ExecuteXmla failed with result
Stack Trace:
Microsoft.PowerBI.Client.Windows.AnalysisServices.XmlaExecutionException
at Microsoft.PowerBI.Client.Windows.AnalysisServices.AnalysisServicesService.ExecuteXmla(String xmla)
at Microsoft.PowerBI.Client.Windows.AnalysisServices.AnalysisServicesService.<>c__DisplayClass45_0.<ImageLoadDatabaseFromPbix>b__0()
at Microsoft.PowerBI.Client.Windows.AnalysisServices.AnalysisServicesService.OnErrorClarify(Action action, String clarification)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.PowerBI.Client.Windows.IExceptionHandlerExtensions.<>c__DisplayClass3_0.<HandleExceptionsWithNestedTasks>b__0()
at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
Stack Trace Message:
ExecuteXmla failed with result
Invocation Stack Trace:
at Microsoft.Mashup.Host.Document.ExceptionExtensions.GetCurrentInvocationStackTrace()
at Microsoft.Mashup.Client.UI.Shared.StackTraceInfo..ctor(String exceptionStackTrace, String invocationStackTrace, String exceptionMessage)
at Microsoft.PowerBI.Client.Windows.Telemetry.PowerBIUserFeedbackServices.GetStackTraceInfo(Exception e)
at Microsoft.PowerBI.Client.Windows.Telemetry.PowerBIUserFeedbackServices.ReportException(IWindowHandle activeWindow, IUIHost uiHost, FeedbackPackageInfo feedbackPackageInfo, Exception e, Boolean useGDICapture)
at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.<>c__DisplayClass15_0.<HandleException>b__0()
at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.HandleException(Exception e)
at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
at Microsoft.PowerBI.Client.Program.Main(String[] args)
PowerBINonFatalError:
{"AppName":"PBIDesktop","AppVersion":"2.97.861.0","ModuleName":"Microsoft.PowerBI.Client.Windows.dll","Component":"Microsoft.PowerBI.Client.Windows.AnalysisServices.AnalysisServicesService","Error":"Microsoft.PowerBI.Client.Windows.AnalysisServices.XmlaExecutionException - PFE_M_ENGINE_INTERNAL,PFE_METADATA_LOAD_FAILED","MethodDef":"ExecuteXmla - PFE_M_ENGINE_INTERNAL,PFE_METADATA_LOAD_FAILED","ErrorOffset":"112"}
InnerException0.Stack Trace Message:
M Engine error: 'Microsoft.Data.Mashup; The type initializer for 'Microsoft.Data.Mashup.MashupConnection' threw an exception.'.
An error occurred when loading the 'dcc69860-2164-43a9-80d1-c6551e32a271', from the file, '\\?\C:\Users\Deepak.Kumar\Microsoft\Power BI Desktop Store App\AnalysisServicesWorkspaces\AnalysisServicesWorkspace_4807a1a9-2f4e-4478-90c8-71d863f24970\Data\dcc69860-2164-43a9-80d1-c6551e32a271.0.db.xml'.
InnerException0.Stack Trace:
InnerException0.Invocation Stack Trace:
at Microsoft.Mashup.Host.Document.ExceptionExtensions.GetCurrentInvocationStackTrace()
at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo.GetFeedbackValuesFromException(Exception e, String prefix)
at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo.GetFeedbackValuesFromInnerExceptions(Exception e, Int32 depth)
at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo.CreateAdditionalErrorInfo(Exception e)
at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo..ctor(String message, Exception exception, Nullable`1 stackTraceInfo, String messageDetail)
at Microsoft.PowerBI.Client.Windows.Telemetry.PowerBIUserFeedbackServices.ReportException(IWindowHandle activeWindow, IUIHost uiHost, FeedbackPackageInfo feedbackPackageInfo, Exception e, Boolean useGDICapture)
at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.<>c__DisplayClass15_0.<HandleException>b__0()
at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.HandleException(Exception e)
at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
at Microsoft.PowerBI.Client.Program.Main(String[] args)
PowerBINonFatalError_ErrorDescription:
PFE_M_ENGINE_INTERNAL,PFE_METADATA_LOAD_FAILED
PowerBINonFatalError_MethodDefDescription:
PFE_M_ENGINE_INTERNAL,PFE_METADATA_LOAD_FAILED
PowerBIUserFeedbackServices_IsReported:
True
Thanks in advance. please some way to open my pbix file.
I am attempting to update the Shipment / Packages tab. The Packages area itself is updating well, but I get an error message when trying to insert into the Package Contents for each of the packages. I believe that the issue is related to needing the ShipmentSplitLineNo as it is a key field that shows on the grid.
This is happening in Acumatica 2019 R2.
Has someone run into this issue and come up with a solution?
I have a custom endpoint, which was extended from the default (18.200.001) and added a section called PackageDetails.
Here is the error message that I get where I do the Post:
System.InvalidOperationException: Unexpected Element: ShipmentPackageDetails
at PX.Api.ContractBased.Soap.EntityReaderBase.ReadEntityField() in E:\Bld6\AC-FULL2019R215-JOB1\Sources\NetTools\PX.Api.ContractBased\Soap\EntityReaderBase.cs:line 288
at PX.Api.ContractBased.Soap.EntityReaderBase.ReadEntity(String expectedEntityType) in E:\Bld6\AC-FULL2019R215-JOB1\Sources\NetTools\PX.Api.ContractBased\Soap\EntityReaderBase.cs:line 161
at PX.Api.ContractBased.Soap.EntityReaderBase.ReadEntity(XmlReader reader, String localname, String expectedNamespace, String expectedEntityType) in E:\Bld6\AC-FULL2019R215-JOB1\Sources\NetTools\PX.Api.ContractBased\Soap\EntityReaderBase.cs:line 53
at PX.Api.ContractBased.Soap.EntityReaderBase.ReadEntityField() in E:\Bld6\AC-FULL2019R215-JOB1\Sources\NetTools\PX.Api.ContractBased\Soap\EntityReaderBase.cs:line 269
at PX.Api.ContractBased.Soap.EntityReaderBase.ReadEntity(String expectedEntityType) in E:\Bld6\AC-FULL2019R215-JOB1\Sources\NetTools\PX.Api.ContractBased\Soap\EntityReaderBase.cs:line 161
at PX.Api.ContractBased.Soap.EntityReaderBase.ReadEntity(XmlReader reader, String localname, String expectedNamespace, String expectedEntityType) in E:\Bld6\AC-FULL2019R215-JOB1\Sources\NetTools\PX.Api.ContractBased\Soap\EntityReaderBase.cs:line 53
at PX.Api.ContractBased.Soap.SoapMessageTransformerBase.BindParameters(XmlReader requestReader, MethodInfo methodInfo, Tuple`2[] parameterInfos) in E:\Bld6\AC-FULL2019R215-JOB1\Sources\NetTools\PX.Api.ContractBased\Soap\SoapMessageTransformerBase.cs:line 104
at PX.Api.ContractBased.Soap.WebApiSoapController.Post(ISoapSystemContract systemContract, XmlReader requestReader, String serviceNamespace, String internalNamespace, MethodInfo method, Func`1 serviceFactory, IEdmModel edmModel) in E:\Bld6\AC-FULL2019R215-JOB1\Sources\NetTools\PX.Api.ContractBased\Soap\WebApiSoapController.cs:line 154
at PX.Api.ContractBased.Soap.WebApiSoapController.<Post>d__8.MoveNext() in E:\Bld6\AC-FULL2019R215-JOB1\Sources\NetTools\PX.Api.ContractBased\Soap\WebApiSoapController.cs:line 140
--- 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 PX.Api.ContractBased.Soap.WebApiSoapController.<Login>d__6.MoveNext() in E:\Bld6\AC-FULL2019R215-JOB1\Sources\NetTools\PX.Api.ContractBased\Soap\WebApiSoapController.cs:line 89
--- 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.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.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.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>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.Web.Http.Controllers.ActionFilterResult.<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 System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()
I have a problem with owin cokies. We have a site powered by ASP.net MVC 5. And authorization is by owin middleware. Sometimes users get a white screen with 500 error. I cant reproduce it at local but a couple of times i could reproduce this case at production. Exploring logs i discovered error "System.NullReferenceException: Object reference not set to an instance of an object."
Stack:
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Owin.Security.DataHandler.Serializer.TicketSerializer.Write(BinaryWriter writer, AuthenticationTicket model)
at Microsoft.Owin.Security.DataHandler.Serializer.TicketSerializer.Serialize(AuthenticationTicket model)
at Microsoft.Owin.Security.DataHandler.SecureDataFormat1.Protect(TData data)
at Microsoft.Owin.Security.Cookies.CookieAuthenticationHandler.<ApplyResponseGrantAsync>d__f.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.Owin.Security.Infrastructure.AuthenticationHandler.<ApplyResponseCoreAsync>d__b.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.Owin.Security.Infrastructure.AuthenticationHandler.<ApplyResponseAsync>d__8.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.Owin.Security.Infrastructure.AuthenticationHandler.<TeardownAsync>d__5.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.Owin.Security.Infrastructure.AuthenticationMiddleware1.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.AspNet.Identity.Owin.IdentityFactoryMiddleware2.<Invoke>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.AspNet.Identity.Owin.IdentityFactoryMiddleware2.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.AspNet.Identity.Owin.IdentityFactoryMiddleware2.<Invoke>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.AspNet.Identity.Owin.IdentityFactoryMiddleware2.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.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.d__5.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.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar)
at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
A part of Startup.Auth:
app.CreatePerOwinContext(Entities.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationRoleManager>(ApplicationRoleManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
//owin иногда теряет куки авторизации в response, поэтому потом возникается nullreference error
//здесь вызывается специальная библиотека, которая сохраняет куки авторизации (создана для фикса бага овина)
app.UseKentorOwinCookieSaver();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/newLogin"),
LogoutPath = new PathString("/logout"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = ctx =>
{
var ret = Task.Run(async () =>
{
Claim claim = null;
int userId = default(int);
User user = null;
try
{
claim = ctx.Identity.FindFirst("SecurityStamp");
if (claim == null) return;
var userManager = new ApplicationUserManager(DependencyResolver.Current.GetService<IUserStore<User, int>>());
userId = ctx.Identity.GetUserId<int>();
user = await userManager.FindByIdAsync(userId);
if (user != null && user.SecurityStamp != null && user.SecurityStamp != claim.Value)
{
var exc = new Exception("ConfigureAuth->OnValidateIdentity->Reject");
exc.Data.Add("claim", claim.Value);
exc.Data.Add("userId", userId);
exc.Data.Add("userStamp", user.SecurityStamp);
ErrorStore.LogException(exc, HttpContext.Current);
ctx.RejectIdentity();
}
}
catch (Exception ex)
{
var exc = new Exception("ConfigureAuth->OnValidateIdentity->catch", ex);
if (claim != null)
{
exc.Data.Add("claim", claim.Value);
}
exc.Data.Add("userId", userId);
if (user!=null)
{
exc.Data.Add("userStamp", user.SecurityStamp);
}
ErrorStore.LogException(exc, HttpContext.Current);
ctx.RejectIdentity();
return;
}
});
return ret;
},
OnApplyRedirect = ctx =>
{
if (!IsApiRequest(ctx.Request))
{
ctx.Response.Redirect(ctx.RedirectUri);
}
},
OnException = (context =>
{
ErrorStore.LogException(context.Exception, HttpContext.Current);
return;
})
}
});
When user gets white screen, he can write into url "logout" and he will be redirected to index page. (domain.me/ru/logout). Or if he clean his cookies he wiil be redirected to index page too.
I installed nuget package "Kentor.OwinCookieSaver" because of i thought owin didn't fixed the bug. But i think it was in vain because i have the latest version of OWIN:
Microsoft.AspNet.Identity.Owin: 2.2.1
Microsoft.Owin: 3.1.0
Microsoft.Owin.Security.OAuth: 3.1.0
Microsoft.Owin.Security.Cookies: 3.1.0
However Owin.Security.Providers is 1.27.0 version because of we dont need for many providers (only facebook and linkedin).
Its a legacy project, so im not deep into it.
I need some help.
Thank you.
Looks like this is AspNetKatana issue, for more details please see https://github.com/aspnet/AspNetKatana/issues/58
Rejected identities would still end up creating an AuthTicket without
a principal. If a sliding refresh was attempted on the same request
then it would NRE on the missing principal.
In GetAuditLogsAsync method, my code:
var query = from auditLog in _auditLogRepository.GetAll()
join user in _userRepository.GetAll() on auditLog.UserId equals user.Id into userJoin
from joinedUser in userJoin.DefaultIfEmpty()
select new {AuditLog = auditLog, joinedUser.NickName};
var count = await query.CountAsync();
When I did a unit test, an error occurred:
System.NullReferenceException : Object reference not set to an instance of an object.
at lambda_method(Closure , TransparentIdentifier`2 )
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
at lambda_method(Closure , QueryContext )
at Microsoft.EntityFrameworkCore.Storage.Internal.InMemoryDatabase.<>c__DisplayClass8_0`1.<CompileAsyncQuery>b__0(QueryContext qc)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync[TSource,TResult](MethodInfo operatorMethodInfo, IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.CountAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at ChiakiYu.AuditLogs.AuditLogAppService.<GetAuditLogsAsync>d__3.MoveNext() in G:\ChiakiYu\ChiakiYu.DotNetCore\aspnet-core\src\ChiakiYu.Application\AuditLogs\AuditLogAppService.cs:line 64
--- 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 Abp.Threading.InternalAsyncHelper.<AwaitTaskWithPostActionAndFinallyAndGetResult>d__5`1.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 ChiakiYu.Tests.Auditing.AuditLogAppService_Tests.<Should_Get_Audit_Logs>d__2.MoveNext() in G:\ChiakiYu\ChiakiYu.DotNetCore\aspnet-core\test\ChiakiYu.Tests\Auditing\AuditLogAppService_Tests.cs:line 75
--- 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)
--- 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)
--- 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)
But when i modify the code:
var query = from auditLog in _auditLogRepository.GetAll()
select new {AuditLog = auditLog};
var count = await query.CountAsync();
it is ok.
Why an error occurs after using join
What should I do ?Thanks.
I know, I'm so stupid.
When the AuditLog.UserId is null, joinedUser is null, joinedUser.NickName is written incorrectly.