Closed zoinkydoink closed 3 years ago
Hi there! In ConfigureService
you can specify which parts of the application you want to disable. For example:
public void ConfigureServices(IServiceCollection services)
{
// Service setup
services.AddPiranha(options =>
{
options.UseArchiveRouting = false;
options.UsePageRouting = false;
options.UsePostRouting = false;
options.UseStartpageRouting = false;
...
}
}
would disable the routing features for:
~/
)This means that no request rewriting will take place and your existing application can just get the data it wants from the IApi
service.
Best regards
You can find the full set of configuration options here:
I have changed startup.cs to following but / results in 404, if i do /index than it pulls my index page (custom), something is still messing with the regular asp.net routing.
I have also attached the zip of the project if that helps WebApplication2.zip
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Piranha;
using Piranha.AttributeBuilder;
using Piranha.AspNetCore.Identity.SQLite;
using Piranha.Data.EF.SQLite;
using Piranha.Manager.Editor;
namespace WebApplication2
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
services.AddRazorPages()
.AddPiranhaManagerOptions();
services.AddPiranha(options =>
{
options.UseArchiveRouting = false;
options.UsePageRouting = false;
options.UsePostRouting = false;
options.UseStartpageRouting = false;
});
services.AddPiranhaApplication();
services.AddPiranhaFileStorage();
services.AddPiranhaImageSharp();
services.AddPiranhaManager();
services.AddPiranhaTinyMCE();
services.AddPiranhaMemoryCache();
services.AddPiranhaEF<SQLiteDb>(db =>
db.UseSqlite("Filename=./piranha.razorweb.db"));
services.AddPiranhaIdentityWithSeed<IdentitySQLiteDb>(db =>
db.UseSqlite("Filename=./piranha.razorweb.db"));
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApi api)
{
App.Init(api);
App.CacheLevel = Piranha.Cache.CacheLevel.Basic;
new ContentTypeBuilder(api)
.AddAssembly(typeof(Startup).Assembly)
.Build()
.DeleteOrphans();
EditorConfig.FromFile("editorconfig.json");
app.UseStaticFiles();
app.UsePiranha();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UsePiranhaIdentity();
app.UsePiranhaManager();
app.UsePiranhaTinyMCE();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
endpoints.MapControllerRoute(name: "default", pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapPiranhaManager();
});
}
}
}
I understand your confusion, the documentation has been updated a lot of times as the startup functionality has changed. As of 9.0
we're consolidating a lot of methods and we will rewrite the docs to make it easier to understand the setup options.
I have pushed an example repo where Piranha is only used as a passive backend for a regular Razor Pages application. You can find it here:
https://github.com/tidyui/piranha-backend
Best regards
Håkan
@zoinkydoink Did you get the example repository to work?
@tidyui i did get that example running, but converting it to .net 5 and integrating rest of my projects seem to cause an error, i opened another issue here https://github.com/PiranhaCMS/piranha.core/issues/1370#issuecomment-710762927
I see that you closed the other issue, but please know that just simply adding a reference to SQL server library crashes the app (sql server is used for other things within my app and not for piranha)
@zoinkydoink You can see the comment on how SqlServer here #1370. Regarding .NET 5
we have never tried it, so there's no guarantee that Piranha is compatible with it. We usually don't look at migrating until versions are officially released.
I seem to be overwhelmed on what is actually required to integrate the CMS into an existing site.
I simply want to use the CMS as a backend.
I think it would be extremely beneficial for everyone to take a bare bone ASP.NET Core website and add Piranha to it so the routes are not altered but still able to utilize the functionality.
Can you let me know or even better (put a tutorial together that goes in the docs) that covers the above? If you do not have time, you can just piece mill it and I can try to put it together.
Razor ASP.NET Core Startup.cs
Piranha Startup.cs