Why does Sitecore throw a NullReferenceException exception when I redirect to one of its pages?
Asked Answered
S

5

5

I'm running Sitecore 6.1 on Windows 2008, IIS7, and I'm trying to use the URL Rewrite Module to do a redirect. When I enable the rule and hit the URL that triggers it, I get a YSOD. The same rule works perfectly on a non-sitecore site on the same machine. According to the Failed Request Trace, the rewrite module does its thing just fine, but then Sitecore throws an exception, even if the redirect points to another server. This is probably a result of something I have misconfigured, but I just can't understand why it doesn't work. The details from the YSOD are below.

[NullReferenceException: Object reference not set to an instance of an object.]  
   Sitecore.Nexus.Web.HttpModule.(Object sender, EventArgs e) +273  
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68  
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75  
Scintillation answered 28/2, 2010 at 15:11 Comment(1)
was there a confirmed solution to this? lack of logging in the module is causing me grief.Larhondalari
A
3

Sitecore has it's own engine for URL redirection, so some wires are probably getting crossed here. Possibly you need to move your HttpModule so it's executing earlier in the chain.

Anabatic answered 1/3, 2010 at 7:14 Comment(5)
The failure trace definitely shows the rewrite happening before the Sitecore pipeline starts. Does it still make sense that things are happening in the wrong order?Scintillation
I suppose not. But it's interesting that this Nexus module is the first Sitecore registered module (I just checked my web.config). Have you tried just removing it? I'm not sure what it does.Anabatic
OK, Nexus is an integral part of Sitecore... can't disable it. Question: What happens when you just browse the target URL in a browser? Same error? What is the full URL? Does it have an extension that Sitecore won't process?Anabatic
@Brian - if you browse to the URL with a 'normal' browser, the page loads fine. It's only when a crawler tries to access the rewritten URL that it throws up the 302 'object moved' error. At least that's what is happening in our case.Chaucerian
How is this an answer? I am running into same problem but not sure what has fixed it or what is the solution? For me, it was all working fine and suddenly after unrelated deployment it has stopped. Any ideas?Giesecke
S
2

Sitecore claim to have fixed this in release 6.2 rev.100831 (Update-4) - http://sdn.sitecore.net/Products/Sitecore%20V5/Sitecore%20CMS%206/ReleaseNotes/KnownIssues%20Recommended/Rewriting%20URLs.aspx

Sere answered 6/10, 2011 at 7:50 Comment(0)
L
1

You can get the same error when doing

Response.Redirect("~/SomeUrl.aspx")

within C# code, the way to fix this is to use the overloaded:

Response.Redirect("~/SomeUrl.aspx", true)

which will end the response immediately.

The rewrite module is obviously not ending the request immediately allowing Sitecore to hit this problem. You could get around this problem by creating a module to deal with the redirects or trying to extend the URL Rewrite Module to end the response immediately.

Lavona answered 30/6, 2010 at 21:21 Comment(0)
L
1

Use the pipeline mode "Classic" rather than "Integrated"

http://sdn.sitecore.net/Products/Sitecore%20V5/Sitecore%20CMS%206/ReleaseNotes/KnownIssues%20Recommended/Rewriting%20URLs.aspx

Larhondalari answered 19/7, 2010 at 15:54 Comment(2)
The problem with this 'fix' is that if you're using the new extension-less URL option (that drops the .ASPX extension), you can't run the project in classic mode. It will serve up 404 pages.Chaucerian
@Chaucerian - The funny thing was, after flicking over to classic, then back to Integrated this has now been fixedLarhondalari
G
0

I experienced this in MultiSite instance on Sitecore v6.5, see my answer here: Sitecore NullReferenceException on GetBrowserClassString

Georgena answered 9/7, 2014 at 9:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.