开发者

How to register a IHttpModule in Orchard which has access to the DefaultContentManager (or the equivalent)

I have been trying to write something for orchard which will check all requests for "_escaped_fragment_" signifying a google ajax crawling request and will perform a 301 redirect to the correct resource which needs to be looked up using the DefaultContentManager.

I had done something like this in a previous project by extending IHttpModule and registering it using

<httpModules>
<add name="GoogleRedirect" type="MyNameSpace.GoogleRedirect"/>
</httpModules>

but have found that using the same approach I can't get access to the orchard content manager.

ie. the following doesn't work

_contentManager = DependencyResolver.Current.GetService<IContentManager>();

I also noticed that Orchard uses Autofac and have been trying to get a line similar to ContainerBuilder().Build().Resolve<IContentManager>() working but the ContainerBuilder doesn't seem to be exposed anywhere?

Is there any way of accessing the DefaultContentManager without having to rewrite the code I currenty have? If not is there a special Orchard way of doing this? What is the easiest way to do it and are there any guides to doing anything similar / any bits of code I can examine? I have been reading through the documentation but not sure of the best way of doing it?

Will carry on reading anyway any help appreciated.

Update

After doing some searching I found the following post:

http://www.deepcode.co.uk/2011/05/real-world-orchard-cms-part-4-cleaning.html

Which has an example of usi开发者_高级运维ng filters. Just in case anyone else has any problems, I found that my Themes folder was never hitting any of the break points. After comparing with another project I noticed that the theme I had created did not have its own project file. To sort this out I recreated my theme using

codegen theme MyTheme /BasedOn:TheThemeMachine /CreateProject:true /IncludeInSolution:true


No, I don't think this is possible. Any particular reason why you need to do this in a module rather than, say, a filter?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜