Setup Wordpress Permalinks on ASP.NET MVC Site - c#

I've got a NopCommerce site (ASP.NET MVC) and I'm trying to add a Wordpress blog as a subfolder of the main site.
The installation of Wordpress was fine, all config files have been created and the blog works fine if you browser through it.
However, I now want to setup pretty permalinks by using the name of the post.
Normally when you setup permalinks, it generates either a .htaccess file for Apache or a web.config for Windows IIS7 Url Rewrites.
When I try and save the permalink settings, it sits there trying to load and eventually times out.
I'm guessing that because ASP.NET MVC uses Routes, the Wordpress site doesn't know what to setup.
Can anyone offer me guidance on how I can get the permalinks setup? Do I need to setup a Route on my MVC site perhaps?

In the end I copied a web.config file from one of my existing blogs that is on a standard C# website.
Normally Wordpress generates the web.config file itself. I can only assume that Wordpress hasn't been setup yet to handle installation on .NET MVC websites.
Creating a web.config file, in the root on the Wordpress blog files, containing the following code should get it working:
<?xml version="1.0" encoding="UTF-8">
<configuration>
<system.webServer>
<defaultDocument>
<files>
<clear/>
<add value="index.php"/>
</files>
</defaultDocument>
<rewrite>
<rule name="wordpress" patternSyntax="wildcard">
<match url="*"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php"/>
</rule>
</rewrite>
</system.webServer>
</configuration>

If you install WordPress on IIS you will notice your friendly URLs do not work. This is because WordPress wants to use an apache add-on called “mod_rewrite.” The quick rundown of that this does is it will take your friendly browser URL and actually change them to index.php on the back end. One problem with this method is that IIS does not load apache mods. Here is an easy and free way around this:
On your IIS Server download and install ISAPI_Rewrite Lite. This filter does the job of mod_rewrite for IIS. When downloading make sure to use the free Lite version. This Lite version does not limit the product very much and will be perfectly fine (and free) for our wordpress blog. Just install Rewrite Lite to the default locations for this tutorial.
Next add the ISAPI filter to your IIS Site.
You will find this setting by right clicking yourIIS site -> properties -> ISAPI filters tab -> Add … Name the filter whatever you wish and your path to your executable should be:
C:\Program Files\Helicon\ISAPI_Rewrite3\ISAPI_Rewrite.dll
Click OK on both windows to save your settings.
Next navigate to C:\Program Files\Helicon\ISAPI_Rewrite3
Here we will edit httpd.conf (Note: This is the difference between the pay version and the Lite version. In the pay version you will need to edit the .htaccess file on your web folders root)
Open the httpd.conf file in wordpad and paste in these lines:
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?p=$1 [NC,L]
Save and exit this file.
To complete your IIS changes, Go to start, run and run the command: iisreset /restart
Now lets change your WordPress settings. Navigate to http://yourblog/wp-admin
Navigate to the left side menu bar -> settings -> Permalinks
Now you get to choose how you want your posts to look. I choose a custom setting and just: /%postname% This is how you see this blog working today.
Click “Save Changes” and you should see your new friendly URLs!

Related

IIS 10 can't read web.config (try to deploy Blazor), Error 500.19 with 0x8007000d [duplicate]

I am replicating web application deployment and found several issues related to HTTP Error 500.19. My machine is running Windows 7 while the working development is using Windows 8. We're developing our Web Application using Visual Studio 2010.
First, I got error code 0x80070021, similar as posted here.
I update my web.config according to the accepted answer and then I got following error code (which is similar as posted here).
HTTP Error 500.19 - Internal Server Error
Error Code 0x8007000d
Config Source -1: 0:
I have read the symptoms definition in Microsoft support page and cause of the error is:
This problem occurs because the ApplicationHost.config file or the Web.config file contains a malformed XML element.
and the solution is
Delete the malformed XML element from the ApplicationHost.config file or from the Web.config file.
However, the web.config that I used is working perfectly in the original development environment.
Here is what I have checked and tried so far:
Install ASP.NET by calling aspnet_regiis -i
Set my application to use different application pool (ASP.NET v4.0, .NET v4, etc)
ApplicationHost.config file is still using default from Windows 7.
This is part of my Web.Config
<system.webServer>
<section name="handlers" overrideModeDefault="Allow" />
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
</modules>
<handlers>
<remove name="UrlRoutingHandler" />
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
<urlCompression doStaticCompression="true" doDynamicCompression="false"></urlCompression>
<directoryBrowse enabled="true" />
<defaultDocument>
<files>
<add value="Logon.aspx" />
</files>
</defaultDocument>
</system.webServer>
I have read similar/duplicates/closed posts (around 13) posts in stackoverflow, tried all except the answer related to Ajax (is it related) and still have no clue on what the error is.
Does anyone one how to fix this error? (And if possible, a comprehensive lists of things need to be checked so we can reduce similar posts like this.) I am ready to provide more details.
Error 0x8007000d means URL rewriting module (referenced in web.config) is missing or proper version is not installed.
Just install URL rewriting module via web platform installer.
I recommend to check all dependencies from web.config and install them.
When trying to set up a .NET Core 1.0 website I got this error, and tried everything else I could find with no luck, including checking the web.config file, IIS_IUSRS permissions, IIS URL rewrite module, etc. In the end, I installed DotNetCore.1.0.0-WindowsHosting.exe from this page: https://www.microsoft.com/net/download and it started working right away.
Specific link to download: https://go.microsoft.com/fwlink/?LinkId=817246
Yes, for .net core apps, install dotnet hosting. This worked for me.
And here it is for .net6
And now if you need .net7
Install URL rewriting:
UPDATE - this is now available here (and works with IIS 7-10):
https://www.iis.net/downloads/microsoft/url-rewrite
Ensure you have the following set to 'Allowed' for your IIS server:
In my case, because I had reinstalled iis, I needed to register iis with dot net 4 using this command:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
In my case (.Net Core Web API) for this issue HTTP Error 500.19 – Internal Server Error 0x8007000d
First download dotnet-hosting-3.0.0-preview5-19227-01-win (.Net Core 3) or dotnetcore 2 hasting windows
https://download.visualstudio.microsoft.com/download/pr/5bed16f2-fd1a-4027-bee3-3d6a1b5844cc/dd22ca2820fadb57fd5378e1763d27cd/dotnet-hosting-3.1.4-win.exe
Any .net core 3.1 application either angular or mvc application would need this.
Second install it as Administrator
Open cmd as administrator, type iisreset, press enter
So refresh your localhost app
Best regard
M.M.Tofighi from Iran
A repair of the DotNetCore hosting bundle did the trick for me. :/
Installing ASP.NET Core Runtime Hosting Bundle solved the issue for me. Source: 500.19 Internal Server Error (0x8007000d)
Kind of late to the party here, but I have just been struggling with the exact same issue (symptoms) and cursing the lack of error detail reporting.
It worked fine on IIS 8+ machines but Win 7 got these INSTANT HTTP 500.19 errors.
For me it was as silly as having an unsupported configuration element in the config file:
<applicationInitialization doAppInitAfterRestart="true">
<add initializationPage="/" />
</applicationInitialization>
So while running old web.config files worked fine, I just diffed them and started chopping away at new blocks until I got the page to start loading. Had I seen this as an answer I would have gone this route immediately as I knew none of the popular solutions were relevant. So there you go :)
I turn on .Net Framework 3.5 and 4.5 Advance Service in Control Panel->Programs and Features->Turn Windows features on or off.it work for me.
Problem solved. Here are the steps that I tried:
Enable the 32-bit application in IIS -> Application pool -> Advanced settings
Copy System.EnterpriseServices.dll and System.EnterpriseServices.Wrapper.dll from C:\Windows\Microsoft.NET\Framework\v2.0.50727 to the application bin folder
Do comments/uncomments to sections on the web.config and found that problem related to the referenced DLL.
The config that I commented the previous one that I added:
<section name="handlers" overrideModeDefault="Allow" />
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Allow"/>
Add the required FasterFlect.DLL used by Combres.DLL v2.1.0.0 to the application bin folder (shall download the full zip from Combres codeplex, because the required fasterflect DLL V2.0.3732.24338 cannot be found in fasterflect codeplex) and other DLLs. For convinience, use the full Combres.DLL (1,3MB)
Check that the DLL versions and public key tokens are configured correctly in web.config using tool, e.g. .NET Reflector
I understand that this error can occur because of many different reasons. In my case it was because I uninstalled WSUS service from Server Roles and the whole IIS went down. After doing a bit of research I found that uninstalling WSUS removes a few dlls which are used to do http compression. Since those dlls were missing and the IIS was still looking for them I did a reset using the following command in CMD:
appcmd set config -section:system.webServer/httpCompression /-[name='xpress']
Bingo! The problem is sorted now. Dont forget to run it as an administrator. You might also need to do "iisreset" as well. Just in case.
Hope it helps others.
Cheers
For me, it was all about setting up my web server to use the latest-and-greatest tech to support my ASP.NET 5 application!
The following URL gave me all the tips I needed:
https://docs.asp.net/en/1.0.0-rc1/publishing/iis-with-msdeploy.html
Hope this helps :)
I had this problem with a brand new web service. Solved it by adding read-only access for Everyone on Properties->Security for the folder that the service was in.
I had the exact same error. It turned out that it was something was caused by something completely, though. It was missing write permissions in a cache folder. But IIS reported error 0x8007000d which is wildly confusing.
I have the same problem when I was trying to publish asp.net core 5.0 web app on my local IIS and the solution was to add the following inside System.webserver tag in my web.config file
<applicationInitialization doAppInitAfterRestart="true">
<add initializationPage="/" />
</applicationInitialization>
Reinstalling ASP.NET Core Runtime - Windows Hosting Bundle Installer made the trick for me... I belive the "ASP.NET Core Module" was missing.
For me I had a web.config file in one my root folders, this config file was for the live server so removing it allowed the site to run on the dev server.
So check for any web.config files in folders too.
In my case, i have installed dotnet hosting but error change to HTTP Error 503. The service is unavailable, but after install windows update KB2999226 and dotnet sdk, its work!
follow the procedure chronologically or it might fail due to missing or errors in redirecting.
install Runtime bundle e.g.. dotnet-sdk-7.0....
2.turn asp services on and internet services"Turn Windows features on or off" to enable IIS
3.install web hosting bundle iis 7.0 e.g dotnet-hosting-7.0.2...
this worked for me

IIS: how to add a module to be run by the Default Web Site?

I have a couple of web applications deployed in an IIS Server (IIS 7.5 in W2k8 R2). In order to remove some HTTP Response Headers, I created a module (C# .dll), copied this .dll to each bin folder of each web application, and reference this module in the web.config of each one like below:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="MyModule" type="MyNamespace.MyClass" />
</modules>
</system.webServer>
From that point on, when I check the Module section of the web application in IIS, the reference is there and it works fine (the headers are not in the HTTP response).
PS.: I was not successful in using the GAC, anyways...
Here is what happens:
when I connect to https://example.com/myapp the header is not present in the response, as expected.
when I connect to https://example.com the header is present, as I didn´t want, but that is expected because I didn´t touch the Default Web Site at this point. Also, this Default Web Site is just an HTML redirection to one of the webapps.
The problem is, when it comes to the Default Web Site, I can´t find its web.config, nor do I find the place where I drop the .dll. Can anyone help?
IIS has a global machine-level configuration file. All web.config files are essentially inheriting from that one. It works something like this (source):
You could simply add your module into the machine.config file and it will automatically be added to all sites. See this question to locate that file.

ASP. Net application is working fine with specified route url but not working with http://locahost

I have an ASP.Net application. The application is working when the url is http://locahost/device.aspx but not working when the given url is just http://locahost. It is throwing an IIS exception and the IIS image is displayed when http://locahost is given
IIS image displayed
If you are using IIS, you need to set the default page in your IIS server. You can check the steps online as it varies from version to version.
Another way thorough web.config, you need to add following tag in your web.config file
<configuration>
<system.webServer>
<defaultDocument enabled="true">
<files>
<add value="device.aspx" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
Because you don't have a default.aspx page.
IIS searchs the Default.aspx if you don't define in the url the page that you want to display . If Default.aspx doesn't exist, it can't decide which page to display.
If you don't have a Default aspx, you should add your device.aspx in the iis manager to your site like on the image.
First, you should open the iis manager (you can type Windows + R to execute the command inetmgr in order to open the iis manager).
Than you expand the server and Default Web site and choose your application.
Double click on the Default Documents and add a new default documents like on the image.
If you want to refer the default web site to your application in order to use only http://localhost url, you can configure your iis like on the second image

'The controller for path '/favicon.ico' was not found...' error

We're building an ASP.NET MVC 4 app in Visual Studio 2015. The app uses Elmah.MVC for exception handling. We're three developers; for two of us it's working fine on localhost, but one developer is getting this error (captured by Elmah):
The controller for path '/favicon.ico' was not found or does not implement IController.
This post provides a solution, and I've modified the routes to include it and the developer in question has synced his code:
routes.IgnoreRoute("{*favicon}", new { favicon = #"(.*/)?favicon.ico(/.*)?" });
Now nothing shows up in Elmah but the user continues to see a generic error:
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
What could be going on? Thanks.
Update 1: Ripped out the Elmah stuff from Web.config and just had the developer load the app. It gets into an infinite loop trying to authenticate the user, similar to this.
We're using OWIN-MixedAuth, and the issue is more than likely on the IIS Express settings. I'll have the developer try it tomorrow and confirm:
Highlight the project in Visual Studio
Open the 'Properties' panel on the right (or press F4)
Set 'Windows Authentication' to 'Enabled'
Set 'Anonymous Authentication' to 'Enabled'
As the name suggests, it's mixed auth, so both types of authentication have to be enabled.
Update 2: The OWIN-Mixed Auth issue has been fixed. Now, it has something to do with these three HTTP modules in Web.config used by Elmah:
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>
When we comment them out, the one developer is able to get onto the site. What do these modules do? Why would they cause a problem?
Finally resolved the issue. We had to make two changes:
We're using OWIN-MixedAuth, and part of the issue was on the IIS Express settings (under "Development Server" section):
Highlight the project in Visual Studio
Open the 'Properties' panel on the right (or press F4)
Set 'Windows Authentication' to 'Enabled'
Set 'Anonymous Authentication' to 'Enabled'
Another part of the issue: a corrupted applicationhost.config file used by IIS Express:
Ensure you're showing hidden files in Windows Explorer.
Go to the root of your project via Windows Explorer.
Open the hidden .vs folder.
Go to config > applicationhost.config, make a backup, and open it in Notepad (Notepad++ is better).
Compare it to a working applicationhost.config file from one of our machines. We found lots of old sites that were listed in the config file which were not being used anymore.
Once cleaned up, launched the app and it worked.
Add this to your global.asax file.
routes.IgnoreRoute("favicon.ico");

Setting Default Page in EC2

I am working on hosting a website developed using asp.net to AWS. I have successfully published it to EC2 instance. I want to setup Index.aspx page as default page so that if someone open the URL it should automatically load index.aspx page e.g. typing www.domain.com opens up index.aspx page. I have tried all the options but somehow its not working for me. Any suggestions will be highly appreciated.
For IIS Web Server you should look at the web.config file.
Make sure you have <defaultDocument enabled="true">
The default files in recent IIS version are (in order)
index.htm
index.html
default.asp
default.aspx
index.asp
index.aspx
index.cfm
index.php
default.htm
If you don't enable the default list, you would need to make sure your index file is added to the list
<defaultDocument>
<files>
<add value="index.aspx"/>
<add value="..."/>
</files>
</defaultDocument>

Categories

Resources