This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//requires package installation | |
//install-package ServiceStack.Logging.NLogger; | |
//requires using statements | |
//using ServiceStack.Logging.NLogger; | |
//using ServiceStack.Logging; | |
//add this to public override void Configure(Container container) method | |
LogManager.LogFactory = new NLogFactory(); | |
container.Register<ILog>(ctx => LogManager.LogFactory.GetLogger(typeof(IService))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PM> Install-Package ServiceStack.Api.Swagger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PM> Install-Package ServiceStack.Logging.NLog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//contructor inject example | |
public class SomeClass | |
{ | |
public ILog Logger { get; set; } | |
public SomeClass(ILog _logger) | |
{ | |
Logger = _logger; | |
} | |
//resolve ILog object in method | |
public SomeMethod() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//4. setup custom routes for login and log out | |
Dictionary<Type, string[]> serviceRoutes = new Dictionary<Type, string[]>(); | |
serviceRoutes.Add(typeof(AuthenticateService), new[] { "/Account/Login", "/Account/{Provider}" }); | |
authFeature.ServiceRoutes = serviceRoutes; //specify manual auth routes | |
//5. Exclude Role and Registration related services | |
authFeature.IncludeAssignRoleServices = false; | |
authFeature.IncludeRegistrationService = false; | |
//6. setup other properties | |
authFeature.GenerateNewSessionCookiesOnAuthentication = true; | |
authFeature.DeleteSessionCookiesOnLogout = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//AppHost.cs, Configure method | |
AuthFeature authFeature = new AuthFeature(() => new UserSession(), new IAuthProvider[] { | |
container.Resolve<IAuthProvider>(), | |
new JwtAuthProvider(AppSettings) //=> use DI to register | |
{ | |
AuthKeyBase64 = ConfigurationManager.AppSettings["jwt.AuthKeyBase64"], | |
RequireSecureConnection = false, //dev configuration | |
EncryptPayload = false, //dev configuration | |
HashAlgorithm = "HS256" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JsConfig.AssumeUtc = true; | |
JsConfig<DateTime>.SerializeFn = time => new DateTime(time.Ticks, DateTimeKind.Local).ToString("o"); | |
JsConfig<DateTime?>.SerializeFn = time => time != null ? new DateTime(time.Value.Ticks, DateTimeKind.Local).ToString("o") : null; | |
JsConfig.DateHandler = DateHandler.ISO8601; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<nlog throwExceptions="true" throwConfigExceptions="true" internalLogLevel="Trace" autoReload="true" xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
<targets async="true"> | |
<target name="file" xsi:type="File" fileName="${basedir}/Logs/Logs.log" layout="${date}: ${message}" /> | |
</targets> | |
<rules> | |
<logger name="*" minlevel="Info" writeTo="file" archiveFileName="${basedir}/archives/log.{#####}.txt" archiveAboveSize="1024" archiveNumbering="Sequence" concurrentWrites="true" keepFileOpen="false" encoding="iso-8859-2" /> | |
</rules> | |
</nlog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.GlobalRequestFilters.Add((req, res, requestDto) => | |
{ | |
if (requestDto != null && requestDto is QueryBase) | |
{ | |
var dto = requestDto as QueryBase; | |
if (dto.Take == null) | |
{ | |
dto.Take = 100; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Plugins.Add(new AutoQueryFeature() | |
{ | |
MaxLimit = 100 | |
} |
OlderNewer