默认认为你手中已经有abp-zero项目,当前4.6.0
angularJS切换到jquery
运行项目,初始化是跳转到~/App/common/views/layout/layout.cshtml,使用的angularJS
想使用jquery版本,需要修改 Web\Controllers\ApplicationController.cs,当然我们新添加的功能也是放到 Areas/Mpa/ 下
ps:Mpa 在这里是多页面的意思
namespace MyCompanyName.AbpZeroTemplate.Web.Controllers{ [AbpMvcAuthorize] public class ApplicationController : AbpZeroTemplateControllerBase { [DisableAuditing] public ActionResult Index() { /* Enable next line to redirect to Multi-Page Application */ return RedirectToAction("Index", "Home", new { area = "Mpa" }); //return View("~/App/common/views/layout/layout.cshtml"); //Layout of the angular application. } }}
切换多租户
修改 Core\AbpZeroTemplateConsts.cs
public class AbpZeroTemplateConsts { public const string LocalizationSourceName = "AbpZeroTemplate"; ////// 是否启用多租户 /// public const bool MultiTenancyEnabled = true; }
webapi跨域访问
引用 Microsoft.AspNet.WebApi.Cors
namespace MyCompanyName.AbpZeroTemplate.WebApi{ ////// Web API layer of the application. /// [DependsOn(typeof(AbpWebApiModule), typeof(AbpZeroTemplateApplicationModule))] public class AbpZeroTemplateWebApiModule : AbpModule { public override void Initialize() { IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()); //Automatically creates Web API controllers for all application services of the application Configuration.Modules.AbpWebApi().DynamicApiControllerBuilder .ForAll(typeof(AbpZeroTemplateApplicationModule).Assembly, "app") .Build(); Configuration.Modules.AbpWebApi().HttpConfiguration.Filters.Add(new HostAuthenticationFilter("Bearer")); var cors = new EnableCorsAttribute("*", "*", "*");//添加跨域支持代码 GlobalConfiguration.Configuration.EnableCors(cors);//添加跨域支持代码 ConfigureSwaggerUi(); //Remove this line to disable swagger UI. } //...... }}
注释SPA菜单,启用Redis,启用HangFire
路径:web\app_start\abpzerotemplatewebmodule.cs
public class AbpZeroTemplateWebModule : AbpModule { public override void PreInitialize() { //Use database for language management Configuration.Modules.Zero().LanguageManagement.EnableDbLocalization(); //Configure navigation/menu //Configuration.Navigation.Providers.Add();//SPA! Configuration.Navigation.Providers.Add (); Configuration.Navigation.Providers.Add ();//MPA! Configuration.Modules.AbpWebCommon().MultiTenancy.DomainFormat = WebUrlService.WebSiteRootAddress; //HangFire Configuration.BackgroundJobs.UseHangfire(configuration => { configuration.GlobalConfiguration.UseSqlServerStorage("Default"); }); //Redis Configuration.Caching.UseRedis(); }
启用HangFire
路径:Web\App_Start\Startup.cs
public class Startup { public void Configuration(IAppBuilder app) { //其它代码.........//Enable it to use HangFire dashboard (uncomment only if it's enabled in AbpZeroTemplateWebModule) app.UseHangfireDashboard("/hangfire", new DashboardOptions { Authorization = new[] { new AbpHangfireAuthorizationFilter(AppPermissions.Pages_Administration_HangfireDashboard) } }); }
注释多余语言列表
修改数据库AbpLanguages
不包装API返回的数据
action上加DontWrapResult特性
[DontWrapResult]