1

My hosting plan includes 1 site. I have installed a Asp.Net MVC Core 2 project on that site and it is working as designed. Now I would like install a blog on the same site in a subdirectory. The blog I am using is Wordpress. Wordpress is installed to a subdirectory on the Asp.Net MVC Core 2 site. When I run the Wordpress blog I get a .NET error page with the error:

Status Code: 404; Not Found

if the Asp.Net MVC Core 2 site runs at www.example.com, i want the blog site to run at www.example.com/blog

I assume Asp.Net MVC Core 2 is looking for a BlogController when I go the blog directory. Is there a setting in IIS7 or Asp.Net MVC Core 2 (Startup.cs or other config file) that tells it to leave the blog directory alone and not use .NET?

Note: i read MVC3 web site with Wordpress in subdirectory, but it is for MVC3 not Asp Net MVC core 2

6
  • 1
    You can add an ignore route to your Startup.cs, but I wouldn't recommend ASP & WP combination in the same hosting. Wordpress sucks and very slow. It is hard to configure it properly on the same hosting and it will kill your ASP performance. You can either install an ASP blog library, or get a separate hosting for WP and redirect the subdirectory to there at the hosting (it will redirect even before reaching ASP, so you don't have to change anything) using a subdomain blog.example.com (you can do this with your current configuration if you really want to ignore my advice above). Commented Jun 16, 2018 at 12:53
  • Thanks for reply, unfortunately ignore route not valid in asp net core, i read stackoverflow.com/questions/39517816/… about ignore route but i don't know what i should replace with context.Response.StatusCode = 404. thanks for your offer about using another host but now I like to know how to solve problem regardless the performance :)) is there anyway? Commented Jun 16, 2018 at 13:19
  • Yes, by "ignore route", I was not referring to the IgnoreRoute() method which is not available for Code. It is better to do the redirection in IIS instead, but most shared hosting providers limit what you can do with IIS, so see my answer for an alternative approach. Commented Jun 16, 2018 at 13:35
  • really thanks for detail description, I do your alternative approach, upload wordpress to blog subdirectory and create blog subdomain, and redirection happens from blog.example.com to example.com/blog but still give me "404 Not found" ! :( Commented Jun 16, 2018 at 13:47
  • That's not right, the redirection shouldn't change from blog.example.com to example.com/blog. It should stay as blog.example.com in the URL. Talk to your hosting provider to see if they can help configure it properly. They will need to exclude the /Blog folder from ASP in IIS. If they cannot help, you will have to ignore the route using the middleware. See how UseStaticFiles() does it for static files and try to mimic the code. Commented Jun 16, 2018 at 14:41

1 Answer 1

0

You can add an ignore route to your Startup.cs, but it is better to configure it directly in IIS instead. Most hosting providers allow you to create subdomains, so you can create blog.example.com and redirect it to the subfolder /blog. This redirection will be done at IIS level and before the request even reaches ASP.Net, so you don't have to change anything.

Sign up to request clarification or add additional context in comments.

1 Comment

If subdomain would be an option, than two separate websites with the different host name bindings would be a simple solution. Probably for some reasons (SEO or technical, or cost) the subdomain does not play

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.