Try our conversational search powered by Generative AI!

404 page redirects

Vote:
 

Hi,

I'm using this article to try and implement proper 404 redirects:

 http://labs.episerver.com/en/Blogs/Svante-Seleborg/Dates/2008/10/When-a-404-Not-Found-should-be-a-404-Not-Found/

But I can't get his url rewriting provider to work. He admits at the bottom that he did it from memory, but my knowledge of this part of the framework is pretty non-existent, so I'm not sure what's going wrong!

As you can see from the comments listing at the bottom of the page, I thought I had it, but it wasn't quite as simple as that.

He's overriding a method called HtmlRewriteUrl, but that method isn't exposed in the class of HtmlRewriteToExternal that he's inheriting. However, the method IS available in the FriendlyHtmlRewriteToExternal class, but when trying to use it, I get an error saying that HtmlRewriteToExternal doesn't have any constructors with zero parameters specified!

I'm a bit stuck, so would appreciate some help very very much on how I can get this handy little provider to work!

Thanks very much,

Karl. 

#31903
Aug 14, 2009 11:57
Vote:
 

Hi,

 Have a look at this module instead: https://www.coderesort.com/p/epicode/wiki/404Handler

I have recommended it before and it works great. You can also have a look on labs.episerver.com and search for 404 Joel have a simple example of 404 as well: http://labs.episerver.com/en/Blogs/Joel-Abrahamsson/Dates2/2009/5/A-simple-solution-for-custom-404-pages-and-permanent-redirects/

/Eric

#31934
Edited, Aug 17, 2009 16:15
Vote:
 

Wow terrific! I'll take a look at both of those and weigh up which one will suit me better.

Thanks very much!

Karl. 

#31956
Aug 18, 2009 13:24
Vote:
 

Okay, I've tried to use Joel's, but I'm using IIS 6 rather than IIS 7.

Can I still use the httpErrors tag, or is it not allowed in IIS 6?

I've tried using Customerrors but can't get the page to capture!

I've created a page in /templates/public/error/pagenotfound.aspx and a pagetype within the episerver cms, then put this into the web.config:

 <customErrors defaultRedirect="/pagenotfound" mode="On"> <error statusCode="404" redirect="/pagenotfound" /> </customErrors>

 where pagenotfound is specified in the page's "page name in web address" field.

My newly created  pagenotfound episerver page is also in the root of the site, so I'm a bit stuck as to why it won't capture! 

Cheers,

Karl. 

#31969
Aug 18, 2009 17:10
Vote:
 

Hi,

 Do not remember exactly byt it is not the samer for iis7 as it is for iis6. I would recommend you to use the epicode module instead.

Have a look at this post and see if it can help you a little bit. We had some problems with custom errors in r2 as well and this post also mention the changes between iis7 and iis6.

 Sorry to say but havent looked at Joel solution before..

 /Eric

#31984
Aug 19, 2009 10:59
Vote:
 

Thanks for your help Eric,

Regardling Joel's example, I found that it was also catching urls to imagery that weren't found, so missing favicons and jpegs were also calling that 404 page, which isn't ideal. This may've been a problem with my implementation though, so I take it back if I did it wrong! :)

As for the epicode module, it seems to have worked a treat! I've put it in with some example code, and I'm capturing the error page and controlling the redirects my own way as well. So overall, very pleased!

Thanks!

Karl. 

#32034
Aug 20, 2009 11:54
Vote:
 

Hi,

As a continuation of my previous post, I've had no trouble with getting the EPiCode module working with IIS 6.0 boxes, but I now have to get the same site running on IIS 7. However, I can't get it to work.

The weirdest thing is when I try to access my custom 404 error template.

When I access any other template it works fine, but when I try to see the error template, it throws the standard 404 page at me. This works on IIS 6, so any thoughts why this might not work on IIS 7? Are there any special circumstances I've not found out about?

Thanks,

Karl.

#32977
Sep 28, 2009 11:15
Vote:
 

Hello Karl,

Did you ever manage to solve the problem with the 404handler on IIS7? We're having the same problem here getting it to run in IIS7, works fine on our development machines but not when we deploy to our stage- and production servers.

Any help is greatly appreciated :-)

/Martin

#35056
Nov 26, 2009 11:12
Vote:
 

I have got the one to work on iis7 but i can't get this to work on iis6 for some reason(code resort module).  is there anythign special i need to do for iis6.

In iis7 you need to select error pages then on the right, select edit feature,  then got to EDIT FEATURE SETTINGS.  There yu need to select Custom error pages and make sure you page under default page is ~/util/notfound.aspx and path type: redirect

the in the custom error page, select Execute a url on this site: set it to /404NotFound.aspx(whatever your document name is) and then click okay.  Should take care of it for you.

Could someone please help me with the code resort module on IIS6

Thank, Joshua Folkerts

#35289
Edited, Dec 02, 2009 20:50
Vote:
 

Remember to add the Http Module under the system.web in the web.config file, and not under system.webServer (IIS 7).

Hope this helps.

#35290
Dec 02, 2009 21:34
Vote:
 

This is the current setup in the web.config for iis6

<httpModules>
<add name="InitializationModule" type="EPiServer.Web.InitializationModule, EPiServer"/>
<add name="BasicAuthentication" type="EPiServer.Security.BasicAuthentication, EPiServer"/>
<add name="Initializer" type="EPiServer.Scheduler.Initializer, EPiServer.Scheduler"/>
<add name="WorkflowRuntime" type="EPiServer.WorkflowFoundation.WorkflowSystem, EPiServer.WorkflowFoundation"/>
<add name="UrlRewriteModule" type="EPiServer.Web.UrlRewriteModule, EPiServer"/>
<add name="WebDav" type="EPiServer.WebDav.Module, EPiServer.WebDav"/>
<add name="EventSubscriberHostModule" type="EPiServer.EventSubscriberHostModule, EPiServer"/>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="BVNetwork.EPi404" type="BVNetwork.FileNotFound.Handler.CustomFileNotFoundHandler, BVNetwork.EPi404"/>
</httpModules>

<appSettings>
<add key="EPsBvn404HandlerRedirectsXmlFile" value="~/CustomRedirects.config"/>
<add key="EPsBvn404HandlerPage" value="~/404NotFound.aspx"/>
<add key="EPsBvn404HandlerMode" value="On"/>
</appSettings>

#35291
Dec 02, 2009 22:38
Vote:
 

Presuming that this is pulled from the <system.web> section. Try moving <add name="BVNetwork.EPi404" type="BVNetwork.FileNotFound.Handler.CustomFileNotFoundHandler, BVNetwork.EPi404"/> to the top of the list (HTTP modules get executed from top to bottom).

#35292
Dec 02, 2009 22:42
Vote:
 

Thanks for your replies, a couple of questions and comments though:

Joshua: Do I really need to go in to the IIS to get this up and running?

Frederik: If I place it in <system.web><HttpModules> I only get a 500-error. We're running our site in Integrated mode and if I understand it correctly we can't have modules in the "old" httpmodules part of web.config when using this mode? Do you mean that we have to run our site in classic mode to get the 404-module to work? Not an optimal solution in my opinion.

Best regards

Martin

#35471
Dec 11, 2009 14:10
Vote:
 

<system.Web> is used by IIS 6, and IIS 7 in classic mode, if you're running IIS7 and integrated mode you should place the Http module under the <system.webServer> section. Also try adding it to the top of the list to make sure it works.

#35472
Dec 11, 2009 14:21
Vote:
 

Hi all,

I've been doing some further work into this.

I've had the site working fine under IIS 7, using all of the information supplied above, but there are still problems with this and IIS 6.

What I've done is a combination of a few things. I've used Joel's blog - http://labs.episerver.com/en/Blogs/Joel-Abrahamsson/Dates2/2009/5/A-simple-solution-for-custom-404-pages-and-permanent-redirects/

I've also used the 404 epicode module.
https://www.coderesort.com/p/epicode/wiki/404Handler

I've used the epicode module to capture the 404 and Joel's blog to handle what happens next (301 redirects, custom 404 page displays, and so on).

This works with IIS 7, but not IIS 6, as some of you have said.

At first, I was getting errors installing the 404 epicode module in EPiServer 5.2.236. This was because the epicode module needed references in the webconfig to dependent assemblies.

What I had was:

  <runtime>
    <assemblyBinding>
      <dependentAssembly />
    </assemblyBinding>
  </runtime>

 

But what I needed was:

<runtime>
    <assemblyBinding>
      <dependentAssembly />
      <dependentAssembly xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
      <dependentAssembly xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="ElektroPost.Licensing" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.BaseLibrary" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.Blog" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.Configuration" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.Enterprise" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.Events" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.ImageLibrary" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.Implementation" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.Legacy4" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.Log.Analyzers" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.Log.Core" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.Lucene" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.Scheduler" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.Scheduler.WKTL" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.1.422.4" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.UI" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.Web.WebControls" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.WebDav" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.WebParts" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.WorkflowFoundation" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.Wsrp" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.XForms" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EPiServer.XmlRpc" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
        <bindingRedirect oldVersion="5.0.0.0-5.65535.65535.65535" newVersion="5.2.375.236" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821" culture="neutral" />
        <bindingRedirect oldVersion="1.0.0.0-1.65535.65535.65535" newVersion="1.2.10.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Web.Services3" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="3.0.0.0-3.65535.65535.65535" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

 

I copied that runtime tag from a previously working example. Why that tag's empty for my new project and not my old one, I have no idea!

The redirects now work using the EPiCode module for aspx pages, but not for /thispage/ (when url rewriting is used). I've tried moving the httphandler to the top of the page, but it doesn't make a difference. In my rush to fix 404 pages, I thought I'd fixed this, when in fact it's always been broken for me!

Does anybody have any idea why http://siteurl/dave.aspx goes to a 404 page as expected, but http://siteurl/dave/ does not?

Cheers!

#38250
Apr 06, 2010 12:20
Vote:
 

I've had a look at the epicode buglist, and this has sprung up:

https://www.coderesort.com/p/epicode/ticket/128

 

It's an accepted defect that it doesn't accept rewritten urls properly in IIS 6 - It might be worth warning people not to take this approach with IIS 6!

Furthermore, I've got a HTML page with a meta redirect tag that now redirects to my 404 page. This html page is referenced in my IIS error pages tab for 404 redirects. Bit of a nasty work-around really!

#38252
Apr 06, 2010 13:06
Vote:
 

I've now fixed the issue with IIS 6.0 and the EPiCode 404 module not working for wildcard mapping. Here's how I fixed it:

Installed the 404 module.

Added the runtime references mentioned above to my web.config.
Configured IIS to explicitly recognise the aspx extension, as per this link: https://www.coderesort.com/p/epicode/ticket/128
Under custom errors tab, change 404 error messages to point to my new error.aspx page.

If you want to use CMSable pages for 404s, you need to reference the aspx page within your custom errors tab in IIS. No friendly URLs!

I got around this by including a new key in the appsettings of my web.config with the ID of the error page. Then I grabbed this page using:
PageData errorpage = Datafactory.Instance.GetPage(new PageReference(mywebconfigid), LanguageSelector.AutoDetect());
And loaded in my CMSable content.

I also used the latter part of Joel Abrahamsson's blog on 301 redirects for my error page to ensure that 404s and 301s are handled correctly.

If people think it's worth me doing a huge blog on it, I will if it helps. :)

Cheers,

Karl.

 

#38277
Apr 07, 2010 10:17
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.