Skip to content

Commit ddd6ff0

Browse files
committed
Converted Web.Host project to .netcoreapp1.1 #28
1 parent 3f4d05d commit ddd6ff0

File tree

8 files changed

+42
-14
lines changed

8 files changed

+42
-14
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
.vs/
55
obj/
66
bin/
7+
/aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/App_Data/Logs/Logs.txt
8+
aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/App_Data/Logs/Logs.txt

aspnet-core/src/AbpCompanyName.AbpProjectName.Core/Authorization/Users/User.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ public static string CreateRandomPassword()
1515

1616
public static User CreateTenantAdminUser(int tenantId, string emailAddress)
1717
{
18-
return new User
18+
var user = new User
1919
{
2020
TenantId = tenantId,
2121
UserName = AdminUserName,
2222
Name = AdminUserName,
2323
Surname = AdminUserName,
24-
EmailAddress = emailAddress,
25-
//Password = new PasswordHasher<>().HashPassword(password) //TODO: Set Password from out of this class!
24+
EmailAddress = emailAddress
2625
};
26+
27+
user.SetNormalizedNames();
28+
29+
return user;
2730
}
2831
}
2932
}

aspnet-core/src/AbpCompanyName.AbpProjectName.Core/Authorization/Users/UserRegistrationManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public async Task<User> RegisterAsync(string name, string surname, string emailA
5555
Roles = new List<UserRole>()
5656
};
5757

58+
user.SetNormalizedNames();
59+
5860
user.Password = _passwordHasher.HashPassword(user, plainPassword);
5961

6062
foreach (var defaultRole in await _roleManager.Roles.Where(r => r.IsDefault).ToListAsync())

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/AbpCompanyName.AbpProjectName.Web.Host.csproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net461</TargetFramework>
4+
<TargetFramework>netcoreapp1.1</TargetFramework>
55
<PreserveCompilationContext>true</PreserveCompilationContext>
66
<AssemblyName>AbpCompanyName.AbpProjectName.Web.Host</AssemblyName>
77
<OutputType>Exe</OutputType>
88
<PackageId>AbpCompanyName.AbpProjectName.Web.Host</PackageId>
99
<UserSecretsId>AbpCompanyName-AbpProjectName-56C2EF2F-ABD6-4EFC-AAF2-2E81C34E8FB1</UserSecretsId>
1010
</PropertyGroup>
1111

12+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net461' ">
13+
<DefineConstants>FEATURE_SIGNALR</DefineConstants>
14+
</PropertyGroup>
15+
1216
<ItemGroup>
1317
<None Include="App.config" />
1418
<None Update="log4net.config">
@@ -36,14 +40,15 @@
3640
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" />
3741
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.1" />
3842
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
39-
<PackageReference Include="Microsoft.Owin.Cors" Version="3.1.0" />
4043
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
4144
<PackageReference Include="Abp.Castle.Log4Net" Version="2.0.1" />
4245
</ItemGroup>
4346

4447
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
4548
<Reference Include="System" />
4649
<Reference Include="Microsoft.CSharp" />
50+
51+
<PackageReference Include="Microsoft.Owin.Cors" Version="3.1.0" />
4752
</ItemGroup>
4853

4954
<ItemGroup>

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/Controllers/HomeController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public HomeController(INotificationPublisher notificationPublisher)
1919

2020
public IActionResult Index()
2121
{
22-
return Redirect("/swagger/ui");
22+
return Redirect("/swagger");
2323
}
2424

2525
/// <summary>

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/Startup/AbpProjectNameWebHostModule.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Reflection;
22
using Abp.Modules;
3+
using Abp.Reflection.Extensions;
34
using AbpCompanyName.AbpProjectName.Configuration;
45
using Microsoft.AspNetCore.Hosting;
56
using Microsoft.Extensions.Configuration;
@@ -21,7 +22,7 @@ public AbpProjectNameWebHostModule(IHostingEnvironment env)
2122

2223
public override void Initialize()
2324
{
24-
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
25+
IocManager.RegisterAssemblyByConvention(typeof(AbpProjectNameWebHostModule).GetAssembly());
2526
}
2627
}
2728
}

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/Startup/Startup.cs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
using System;
22
using Abp.AspNetCore;
33
using Abp.Castle.Logging.Log4Net;
4-
using Abp.Owin;
54
using AbpCompanyName.AbpProjectName.Configuration;
6-
using AbpCompanyName.AbpProjectName.Owin;
75
using Castle.Facilities.Logging;
86
using Microsoft.AspNetCore.Builder;
97
using Microsoft.AspNetCore.Hosting;
10-
using Microsoft.AspNet.SignalR;
118
using Microsoft.AspNetCore.Mvc.Cors.Internal;
129
using Microsoft.Extensions.Configuration;
1310
using Microsoft.Extensions.DependencyInjection;
1411
using Microsoft.Extensions.Logging;
15-
using Microsoft.Owin.Cors;
12+
using Swashbuckle.AspNetCore.Swagger;
13+
14+
#if FEATURE_SIGNALR
1615
using Owin;
16+
using Microsoft.Owin.Cors;
17+
using Microsoft.AspNet.SignalR;
18+
using AbpCompanyName.AbpProjectName.Owin;
19+
using Abp.Owin;
20+
#endif
1721

1822

1923
namespace AbpCompanyName.AbpProjectName.Web.Host.Startup
@@ -48,7 +52,11 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
4852
});
4953

5054
//Swagger - Enable this line and the related lines in Configure method to enable swagger UI
51-
services.AddSwaggerGen();
55+
services.AddSwaggerGen(options =>
56+
{
57+
options.SwaggerDoc("v1", new Info { Title = "AbpProjectName API", Version = "v1" });
58+
options.DocInclusionPredicate((docName, description) => true);
59+
});
5260

5361
//Configure Abp and Dependency Injection
5462
return services.AddAbp<AbpProjectNameWebHostModule>(options =>
@@ -70,8 +78,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
7078

7179
app.UseStaticFiles();
7280

81+
#if FEATURE_SIGNALR
7382
//Integrate to OWIN
7483
app.UseAppBuilder(ConfigureOwinServices);
84+
#endif
7585

7686
app.UseMvc(routes =>
7787
{
@@ -87,9 +97,13 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
8797
// Enable middleware to serve generated Swagger as a JSON endpoint
8898
app.UseSwagger();
8999
// Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
90-
app.UseSwaggerUi(); //URL: /swagger/ui
100+
app.UseSwaggerUI(options =>
101+
{
102+
options.SwaggerEndpoint("/swagger/v1/swagger.json", "AbpProjectName API V1");
103+
}); //URL: /swagger
91104
}
92105

106+
#if FEATURE_SIGNALR
93107
private static void ConfigureOwinServices(IAppBuilder app)
94108
{
95109
app.Properties["host.AppName"] = "AbpZeroTemplate";
@@ -106,5 +120,6 @@ private static void ConfigureOwinServices(IAppBuilder app)
106120
map.RunSignalR(hubConfiguration);
107121
});
108122
}
123+
#endif
109124
}
110125
}

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/log4net.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8" ?>
22
<log4net>
33
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender" >
44
<file value="App_Data/Logs/Logs.txt" />

0 commit comments

Comments
 (0)