Thanks Aaron - Still no luck. Any other ideas?
It does. I've also created a button in my application that fires off a notification (as a test). Those get to the user without an issue.
I'm having a similar issue as the one presented at: [https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=9887&p=22368&hilit=notification#p22368])
I've gone through the post and am not having any luck. The users never receive the notifications. I can see that the service is getting called because I can set a breakpoint and I can also see the jobs in the Hangfire tables.
Here is my domain service code. Happy to send the project along if it would be easier.
Thanks, Craig
using Abp;
using Abp.Domain.Repositories;
using Abp.Domain.Uow;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TestCode.TestCode.Authorization.Users;
namespace TestCode.TestCode.Notifications
{
public class NotificationDomainService : TestCodeDomainServiceBase, INotificationDomainService
{
//private readonly INotificationDomainService _notificationDomainService;
private readonly IAppNotifier _appNotifier;
private readonly UserManager _userManager;
private IRepository<User, long> _userRepository;
private readonly IUnitOfWorkManager _unitOfWorkManager;
public NotificationDomainService(IAppNotifier appNotifier, IRepository<User, long> userRepository, IUnitOfWorkManager unitOfWorkManager)//, UserManager userManager)
{
_appNotifier = appNotifier;
//_userManager = userManager;
_userRepository = userRepository;
_unitOfWorkManager = unitOfWorkManager;
}
public virtual void NotifyAllForTenantById(int? tenantId, string message = "Domain Service", string severity = "info")
{
using (_unitOfWorkManager.Begin())
{
using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant))
{
var users = _userRepository.GetAllList(u => u.TenantId == tenantId);
UserIdentifier[] userIds = new UserIdentifier[users.Count()];
int i = 0;
foreach (User u in users)
{
UserIdentifier userId = new UserIdentifier(tenantId, u.Id);
_appNotifier.SendMessageAsync(userId, "Hello to All Tenant Users From The Domain Service");
}
CurrentUnitOfWork.SaveChanges();
}
}
}
}
}
Sorry. No. That is how my code has been. This is basically a fresh download of aspnetzero. We were testing some of the new functionality (I think it's 4.3) so there is not any custom code yet.
Thanks. I think that is what we're doing. I basically just un-commented the code in the startup class. My configure method is below.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//Initializes ABP framework.
app.UseAbp(options =>
{
options.UseAbpRequestLocalization = false; //used below: UseAbpRequestLocalization
});
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseStatusCodePagesWithRedirects("~/Error?statusCode={0}");
app.UseExceptionHandler("/Error");
}
AuthConfigurer.Configure(app, _appConfiguration);
app.UseStaticFiles();
app.UseAbpRequestLocalization();
#if FEATURE_SIGNALR
//Integrate to OWIN
app.UseAppBuilder(ConfigureOwinServices);
#endif
//Hangfire dashboard & server (Enable to use Hangfire instead of default job manager)
app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
Authorization = new[] { new AbpHangfireAuthorizationFilter(AppPermissions.Pages_Administration_HangfireDashboard) }
});
app.UseHangfireServer();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "defaultWithArea",
template: "{area}/{controller=Home}/{action=Index}/{id?}");
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
// Enable middleware to serve generated Swagger as a JSON endpoint
//app.UseSwagger();
// Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
//app.UseSwaggerUI(options =>
//{
// options.SwaggerEndpoint("/swagger/v1/swagger.json", "TestCode API V1");
//}); //URL: /swagger
}
We're using the MVC .NET Core version and are trying to enable Hangfire. I followed the instructions to enable the hangfire dashboard found at: [https://aspnetboilerplate.com/Pages/Documents/Hangfire-Integration])
When I try to access the dashboard, I get the following error. Any help would be appreciated.
System.ArgumentException: Context argument should be of type `AspNetCoreDashboardContext`!
Parameter name: context
at Hangfire.Dashboard.AspNetCoreDashboardContextExtensions.GetHttpContext(DashboardContext context)
at Abp.Hangfire.AbpHangfireAuthorizationFilter.IsLoggedIn(DashboardContext context)
at Abp.Hangfire.AbpHangfireAuthorizationFilter.Authorize(DashboardContext context)
at Hangfire.Dashboard.MiddlewareExtensions.<>c__DisplayClass1_1.<UseHangfireDashboard>b__3(IDashboardAuthorizationFilter filter)
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
at Hangfire.Dashboard.MiddlewareExtensions.<>c__DisplayClass1_2.<UseHangfireDashboard>b__1(IDictionary`2 env)
at Microsoft.Owin.Mapping.MapMiddleware.<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.Owin.Mapping.MapMiddleware.<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.AspNetCore.Owin.WebSocketAcceptAdapter.<>c__DisplayClass6_0.<<AdaptWebSockets>b__0>d.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.AspNetCore.Localization.RequestLocalizationMiddleware.<Invoke>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 Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.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 IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationMiddleware.<Invoke>d__7.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.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.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 IdentityServer4.Hosting.IdentityServerMiddleware.<Invoke>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 IdentityServer4.Hosting.FederatedSignOutMiddleware.<Invoke>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 IdentityServer4.Hosting.AuthenticationMiddleware.<Invoke>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 Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.<Invoke>d__7.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 IdentityServer4.Hosting.BaseUrlMiddleware.<Invoke>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 Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.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.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.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.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.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.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.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.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
Do you happen to have an architectural diagram for ASP.NET Zero? Looking for something high level like this. [http://www.reddnet.net/wp-content/uploads/2014/04/ef_domain_model.png])
Well, I found a workaround but I'm not sure if it's the appropriate solution.
In the _Layout.cshtml file there is this code:
<script type="text/javascript">
@* This is used to get the application's root path from javascript.
It's useful if you're running application in a virtual directory under IIS. *@
var abp = abp || {}; abp.appPath = '@ApplicationPath';
</script>
If I change it to:
<script type="text/javascript">
@* This is used to get the application's root path from javascript.
It's useful if you're running application in a virtual directory under IIS. *@
var abp = abp || {}; abp.appPath = '@ApplicationPath' + 'aspnetzero/';
</script>
It works.
Having an issue deploying to a virtual directory that is not the root of the website in IIS. When we deploy, the app renders fine by the service calls have the incorrect URL. Example:
Deploying site to: <a class="postlink" href="http://www.test.com/aspnetzero">http://www.test.com/aspnetzero</a>
When the site renders in the browser, the api calls are made to: <a class="postlink" href="http://www.test.com/api..">http://www.test.com/api..</a>.
Instead of: <a class="postlink" href="http://www.test.com/aspnetzero/api">http://www.test.com/aspnetzero/api</a>
Is there some configuration I can change to make it work? We've already changed web.config to contain:
"App": { "WebSiteRootAddress": "http://www.test.com/aspnetzero/" },
Thanks
Just to close the loop in case anyone else runs into this issue. The only way I could ultimately get our Continuous Integration process to build the .NET Core version was to install the Visual Studio 2017 on the server and then use the command:
devenv MyProject.sln /build Release
I'm not wild about installing VS 2017 on our build server, but it works for now.