Comments (2)
There seems to be a typo in the official documentation. This would be the correct way to add the options in your Program.cs
builder.AddPiranha(options =>
{
...
options.UseManager(o => {
o.JsonOptions = (jsonOptions) =>
{
jsonOptions.SerializerSettings.ContractResolver = new DefaultContractResolver();
};
});
...
});
Regards
from piranha.core.
using System;
using Dapper;
//using Hangfire;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Serialization;
using Piranha;
using Piranha.AttributeBuilder;
using Piranha.ImageSharp;
using Piranha.Local;
//using Piranha.Manager.Binders;
using SendbackPortal.Data;
using SendbackPortal.Jobs;
using SendbackPortal.Models;
using SendbackPortal.Models.AccountViewModels;
using SendbackPortal.Models.Templates;
using SendbackPortal.Repositories;
using SendbackPortal.Services;
using EntityFrameworkCore.UseRowNumberForPaging;
using Microsoft.AspNetCore.Mvc.NewtonsoftJson;
using Newtonsoft.Json;
using Piranha.Manager.TinyMCE;
using Piranha.Data.EF.SQLServer;
using Piranha.Manager.LocalAuth;
using Piranha.Manager.Editor;
namespace SendbackPortal
{
/// <summary>
/// Application configuration
/// </summary>
public class Startup
{
public Startup(IConfiguration configuration, IHostingEnvironment env)
{
Configuration = configuration;
var contentRoot = configuration.GetValue<string>(WebHostDefaults.ContentRootKey);
}
public IConfiguration Configuration { get; }
public string conn;
// This method gets called by the runtime. Use this method to add services to the container.
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// Get connection strings from the appsettings.json file
var defaultConnection = Configuration.GetConnectionString("DefaultConnection");
var advConnection = Configuration.GetConnectionString("ADVConnection");
conn = advConnection;
// BB 5/16/2018 - make compatible with SQL Server 2008R2
services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(defaultConnection, b => b.UseRowNumberForPaging()));
services.AddDbContext<SQLServerDb>(options => options.UseSqlServer(defaultConnection, b => b.UseRowNumberForPaging()));
services.AddDbContext<DefaultDBContext>(options => options.UseSqlServer(defaultConnection, b => b.UseRowNumberForPaging()));
services.AddDbContext<AdvDbContext>(options => options.UseSqlServer(advConnection, b => b.UseRowNumberForPaging()));
//services.AddDbContext<AdvPhysicianMessengerDbContext>(options => options.UseSqlServer(advPhysicianMessengerConnection, b => b.UseRowNumberForPaging()));
// Set up the authentication for the application
services.AddIdentity<ApplicationUser, IdentityRole>(options => {
options.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+/' ";
})
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders()
.AddErrorDescriber<CustomIdentityErrorDescriber>(); // Add this line
services.Configure<DataProtectionTokenProviderOptions>(o => o.TokenLifespan = TimeSpan.FromDays(14));
//services.Configure<DataProtectionTokenProviderOptions>(o => o.TokenLifespan = TimeSpan.FromMinutes(2)); // minutes for testing purposes
// Add Global singletons
services.AddSingleton(Configuration);
services.AddSingleton<IStorage, FileStorage>();
services.AddSingleton<IImageProcessor, ImageSharpProcessor>();
services.AddTransient<ISecurity, IdentitySecurity>();
services.AddScoped<IDb, SQLServerDb>();
services.AddScoped<IApi, Api>();
// Allow the this application to use the Piranha manager
services.AddPiranha(options =>
{
options.UseCms();
options.UseManager(o => {
o.JsonOptions = (jsonOptions) =>
{
jsonOptions.SerializerSettings.ContractResolver = new DefaultContractResolver();
};
});
options.UseFileStorage(naming: Piranha.Local.FileStorageNaming.UniqueFolderNames);
options.UseImageSharp();
options.UseTinyMCE();
//options.UseMemoryCache();
options.UseEF<SQLServerDb>(db =>
db.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
//options.UseIdentityWithSeed<IdentitySQLServerDb>(db =>
// db.UseSqlServer("DefaultConnection"));
});
services.AddTransient<IEmailSender, EmailSender>();
services.AddTransient<IUserRepository, UserRepository>();
services.AddTransient<ISendbackRepository, SendbackRepository>();
services.AddTransient<IUsersMappingRepository, UsersMappingRepository>();
services.AddTransient<IPhysicianMessengerRepository, PhysicianMessengerRepository>();
services.AddTransient<ILocationExclusionRepository, LocationExclusionRepository>();
services.AddSession();
return services.BuildServiceProvider();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider services)
{
// Show useful error messages if the application is in development
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
DefaultTypeMap.MatchNamesWithUnderscores = true;
// Initialize Piranha
var api = services.GetService<IApi>();
App.Init(api);
var pageTypeBuilder = new ContentTypeBuilder(api)
.AddType(typeof(BlogArchive))
.AddType(typeof(StandardPage));
pageTypeBuilder.Build();
var postTypeBuilder = new ContentTypeBuilder(api)
.AddType(typeof(BlogPost));
postTypeBuilder.Build();
EditorConfig.FromFile("editorconfig.json");
// Register middleware
app.UseStaticFiles();
//app.UseRouting();
app.UseAuthentication();
// app.UseAuthorization();
app.UseMiddleware<PasswordMiddleware>();
app.UsePiranha(options =>
{
options.UseManager();
options.UseTinyMCE();
});
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapPiranhaManager();
});
}
}
}
still piranha manger function is breaking ..JSON serialization did not work
from piranha.core.
Related Issues (20)
- HtmlField TinyMCE editor not working in custom region HOT 3
- Piranha.Extend.Blocks.HtmlColumnBlock - Piranha Version 11.0 HOT 1
- Update ImageSharp to 2.1.7 HOT 1
- FieldSettings not being passed to field collection region. HOT 2
- Deserialization issue in AliasService when using distributed cache HOT 5
- Duplicate block
- Which version is LTS, also docs do not show version 11
- Add version param to PublicUrl in FileStorage HOT 5
- Purpose of language setting on site?
- vuejs-datepicker is deprecated HOT 1
- Can't upload images after v11 upgrade HOT 6
- piranha manager json serialization HOT 2
- Brotli Compression Not Working with Piranha CMS HOT 2
- Image Handling question HOT 1
- TinyMCE is changing my markup
- Bad post url returns archive instead of 404 error
- UseIdentityWithSeed does not add the user sysadmin. HOT 2
- No caching used in SiteService.GetAllAsync HOT 1
- Adding Blocks on the fly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from piranha.core.