Same issue
I tried following code to enable CORS but when I'm calling api from another domain, it is still giving error-
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
// Enabling CORS:
var cors = new EnableCorsAttribute(origins: "*", headers: "*", methods: "*");
Configuration.Modules.AbpWebApi().HttpConfiguration.EnableCors(cors);
//Automatically creates Web API controllers for all application services of the application
Configuration.Modules.AbpWebApi().DynamicApiControllerBuilder
.ForAll<IApplicationService>(typeof(ProjectLearnApplicationModule).Assembly, "app")
.Build();
Configuration.Modules.AbpWebApi().HttpConfiguration.Filters.Add(new HostAuthenticationFilter("Bearer"));
ConfigureSwaggerUi(); //Remove this line to disable swagger UI.
}
Do I need to make modifications at any other place? I'm using ASPNET MVC + jQuery
Hi I am trying to use SQL dependency for my Project but it is not running on Asp.Net Zero Environment . I mean i have tried with new blank database or with other .Net Applications it is working fine . but when i am trying to do with Asp.Net Zero Application with Code first then it is not working . Database not firing any notification on data change , Even i have Enable Broker service also . Can anyone help me for this ? I want to use it for update notification for other reason not for Chat .
@ismcagdas, unfortunately it does not work with multi tenancy as well.
Could you please try the following-
int ExpireFromMin = 1;
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
SlidingExpiration = false,
ExpireTimeSpan = TimeSpan.FromMinutes(ExpireFromMin),
Provider = new CookieAuthenticationProvider
{
OnResponseSignIn = signInContext =>
{
signInContext.Properties.IssuedUtc = DateTime.UtcNow;
signInContext.Properties.ExpiresUtc = DateTime.UtcNow.Add(TimeSpan.FromMinutes(ExpireFromMin));
},
}
});
Now after one minute of inactivity, it will redirect you to AD FS for reauthentication. But instead, you'll go in to redirection loop.
Please let me know. This issue is becoming a pressing one.
Thanks.
Is there anyway we can generate JSON object automatically from Enums? So that we won't have to edit JS code everytime we have a new value in Enums.
I found a beatuiful way to do this.. So I thought to share it here as well.
There is lilbrary called Delegate Decomplier..
On high level, we create readonly properties with NotMapped and Computed(provided by DelegateDecompiler) attributes and add all logic in those properties.
When we write query, we only call extra method ".DecompileAsync()" and then ".ToListAsync()", it will automatically modifies the query that can be understood by SQL.
If you want to learn more about it, must read: https://daveaglick.com/posts/computed-properties-and-entity-framework
Hmm.. for simplicity sake I did not post entire conditions.
Please check my updated question. I have included full condition there.
Your solution will not work when user wants to search for a status by text. Any other ideas? Some thoughts I have -
But these will require queries/functions to be stored on SQL Server which I do not like. Any other way to use do this purely using C# ?
Thanks!
Hi,
We have a jtable which have some columns whose value is calculated based on some conditions.
For example-
var documents = await documentsQuery
.OrderBy(input.Sorting)
.PageBy(input)
.Select(x => new DocumentListDto
{
Id = x.Id,
Title = x.Title,
File_Size_Presenter = x.File_Size + " KB",
Document_Approval_Type = x.Entity_Document_Approval_Types.Approval_Type,
Document_Approval_Type_ID_FK = x.Document_Approval_Type_ID_FK,
CreationTime = x.CreationTime,
Approvers = x.Entity_Approvers.Count(),
Status = x.Is_Publish ? "Published" :
x.Document_Approval_Type_ID_FK == (int)Entity_Document_Approval_Types.DEFAULT_TYPES.Sequential ?
(x.Entity_Approvers.Count(a => a.Approver_Type_ID_FK == (int)Entity_Approvers_Types.DEFAULT_TYPES
.Basic) == x.Entity_Approvers.Count(a => a.Is_Approved == true && a.Approver_Type_ID_FK == (int)Entity_Approvers_Types.DEFAULT_TYPES
.Basic) ? "Approved" : "In progress") // Sequential
:
(x.Approvers_Required <= (x.Entity_Approvers.Count(a => a.Is_Approved == true && a.Approver_Type_ID_FK == (int)Entity_Approvers_Types.DEFAULT_TYPES
.Basic)) ? "Approved" : "In progress"), // Numbered
Status2 = x.Is_Publish ? "Document has been published" :
x.Document_Approval_Type_ID_FK == (int)Entity_Document_Approval_Types.DEFAULT_TYPES.Sequential ?
(x.Entity_Approvers.Count(a => a.Approver_Type_ID_FK == (int)Entity_Approvers_Types.DEFAULT_TYPES
.Basic) == x.Entity_Approvers.Count(a => a.Is_Approved == true && a.Approver_Type_ID_FK == (int)Entity_Approvers_Types.DEFAULT_TYPES
.Basic) ?
x.Entity_Approvers.FirstOrDefault(a => a.Approver_Type_ID_FK == (int)Entity_Approvers_Types.DEFAULT_TYPES
.Original_Writer).Is_Approved != true ? "Waiting on original writer" : "Waiting final publishing"
: "Waiting on approvers") // Sequential
:
(x.Approvers_Required <= (x.Entity_Approvers.Count(a => a.Is_Approved == true && a.Approver_Type_ID_FK == (int)Entity_Approvers_Types.DEFAULT_TYPES
.Basic)) ? x.Entity_Approvers.FirstOrDefault(a => a.Approver_Type_ID_FK == (int)Entity_Approvers_Types.DEFAULT_TYPES
.Original_Writer).Is_Approved != true ? "Waiting on original writer" : "Waiting final publishing" : "Waiting on approvers"), // Numbered
Author = x.AbpUser_OriginalWriterUser.Name + " " + x.AbpUser_OriginalWriterUser.Surname,
DocumentAdmin = x.AbpUser_DocumentAdminUser.Name + " " + x.AbpUser_DocumentAdminUser.Surname
})
.ToListAsync();
Here, columns like Status, Status2, Author, DocumentAdmin does not exists in database. Applying filter on them would mean to first fetch all data and then filter it, which does not seem like any efficient way. We are also using paging and sorting and we cannot lose this functionality. (Sorting is not working on calculated columns. So, as a bonus, if you have a solution to that, it'll be much appretiated :) )
I believe many of you, like me, would have banged your head on wall to do this correctly. So, how could this be handled in an elegant way?
Thanks!
@alper, thanks for looking into this issue. After doing in depth assessment on it, I found that other dev mistakenly included jQuery in folder Area/Mpa/Common/Scripts which was conflicting with the jQuery we already have. Removing this file, resolved my issue.
Were you guys able to regenerate this issue?