U4-4280 - Getting server error from UmbracoModule when HttpModule uses context.RewritePath

Created by Robert Ghafoor 21 Feb 2014, 23:21:54 Updated by Robert Ghafoor 23 Feb 2014, 09:45:26

I downloaded and installed https://bitbucket.org/Offroadcode/adaptiveimages-for-umbraco but when i go to a media image i get Object reference not set to an instance of an object from UmbracoModule.

Edit: I have now debugged from umbraco source 7.0.4 and located the problem, it seams that UmbracoContext.Current is null on line 178 and that is cusing the error so i think that checking for null before doing the if (ShouldAuthenticateRequest(req, UmbracoContext.Current.OriginalRequestUrl)) would solve this issue ?

but it seams that line 97 will throw after that... so how can a httpmodule that uses RewritePath get around this as its not a umbraco based request still umbraco tries to use it as one... ?

however if we also change the line 93 to this: if (httpContext.Request.Url.IsClientSideRequest() || UmbracoContext.Current == null)

then it works.

Edit 2: As i don't know way UmbacoModule it is implemented as it is i wonder if instead of changing the code like in edit 1 there could be a configration key in appSettings similar to umbracoReservedUrls that one could add ex ImageGen.ashx and by doing that UmbacoModule will return and not process any ashx files in the config key ?

i tried to fix this problem by not changing the UmbracoModule but could not find any optimal way of doing it.

see attached screenshot.

2 Attachments

Comments

Sebastiaan Janssen 22 Feb 2014, 08:11:01

This is a 3rd party component, please contact the creators of it before reporting bugs here. If it's an actual bug in umbraco itself then it's appropriate to report here.


Robert Ghafoor 22 Feb 2014, 11:25:35

Well i went in to there source code and looked into it before posting and found no problems with it the thing that cuses the problem is that it tries to do this: context.RewritePath(imageGenUrl); the image gen url is String.Format("~/ImageGen.ashx?Image={0}&Width={1}&{2}", filename, bestFitResolution.ToString(CultureInfo.InvariantCulture), context.Request.QueryString);

... i think its a bugg in the UmbracoModule


Robert Ghafoor 22 Feb 2014, 11:26:24

@sebastiaan Well i went in to there source code and looked into it before posting and found no problems with it the thing that cuses the problem is that it tries to do this: context.RewritePath(imageGenUrl); the image gen url is String.Format("~/ImageGen.ashx?Image={0}&Width={1}&{2}", filename, bestFitResolution.ToString(CultureInfo.InvariantCulture), context.Request.QueryString);

and somehow the umbraco module catches the request as it dose so for all requests but it tries to autorize the module that rewrites a imageGenUrl and somewere there it chraches not in the 3rd party module...

I think its a bugg in the UmbracoModule im going to download the source and debug from there then post more info here.


Robert Ghafoor 22 Feb 2014, 17:41:16

@sebastiaan i cant contact any 3rd person as i cant find any contact information nor can i find any optimal way of doing it i tried to programmatically load in the url in a web request and then write to the context but its slow and not as optimal as using RewritePath.


Sebastiaan Janssen 22 Feb 2014, 18:25:47

I'm not sure what you want me to do. Does the 3rd party software work on an earlier version of Umbraco 7? If yes: we screwed up and need to fix it. If no: they screwed up and need to fix it.

I suggest you find a different way of doing what you're trying to do and discuss your options on the forum: http://our.umbraco.org


Robert Ghafoor 23 Feb 2014, 09:45:26

@sebastiaan I had Umbraco v6.0.3 (Assembly version: 1.0.5167.19014) and i tested with that and everyting worked xD anyway, i tested with context.Server.TransferRequest(imageGenServerPath, true); and that seams to work in my umbaco dev envioroment but not in my project il try to find out way but else il look for someting else to use.


Priority: Normal

Type: Usability Problem

State: Closed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.0.4

Due in version:

Sprint:

Story Points:

Cycle: