Closed anilkumarvs closed 1 year ago
Thank you for the question!
There are two options
app.UseWordPress()
after other middlewares.ConfigureServices()
method:
services.AddWordPress(options =>
{
options.HomeUrl =
options.SiteUrl = "https://localhost:5004/wp";
});
Thanks for the help. I tried to implement the change, but still not succeed. Now only wordpress site is showing. Please see my program.cs code below. Can you please have a look and give suggestion.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllersWithViews();
builder.Services.AddSwaggerGen();
builder.Services.AddHttpClient();
builder.Services.AddWordPress(options =>
{
options.HomeUrl = "https://localhost:7288";
options.SiteUrl = "https://localhost:7288/wp";
});
builder.Services.AddAuthentication();
builder.Services.AddHttpContextAccessor();
builder.Services.AddAuthorization();
ConfigurationManager configuration = builder.Configuration;
var app = builder.Build();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseWordPress();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
please see my reply above:
- order matters - write app.UseWordPress() after other middlewares.
Dear Jakub, That worked. Thank you so much. Now both my .net web and wordpress works fine.
I have successfully integrated peachpie wordpress into an ASP.Net Core 6 Web application. But the problem now is, due to routing the current website is not accessible and instead showing the wordpress site as the entry point of the website. I want to move this entire wordpress under a subfolder, may be "content".
I have added some mapping like
app.Map(new PathString("/content"), wordpressApp => { wordpressApp.UseWordPress(); });
This help to access the main website and wordpress (under /Content) separately. But the problem is only wordpress home page is working. The links from wordpress home page and wp-admin etc, are not working due to routing issue.
Can anyone help to fix this issue. Need to access both existing core web app and wordpress simultaneously.