First Custom Module - Cached Behaviour

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
6/15/2012 4:25:07 AM
Gravatar
Total Posts 3

First Custom Module - Cached Behaviour

Greetings to all. I have a new mojoportal setup. I created a new module by copying the SomeModule.ascx already found under Modules folder. I've added a label and wrote a couple of lines to populate it with a date and some strings.

My question: Is there some internal caching mechanism for this kind of modules? While I change my code testing it, I see that the new code executes only after building the project each time. I would prefed to work under debug mode or something, and release when its final. Am I doing something wrong?

Many thanks

6/15/2012 6:50:05 AM
Gravatar
Total Posts 18439

Re: First Custom Module - Cached Behaviour

Hi,

This is normal behavior when your control is in your own custom project and uses codebehind. You should have a post build event that copies your control up to a folder under the Web folder and copies your dll to the Web/bin folder. Your control can only run in the context of its copied location in the mojoPortal.Web project, so after making any changes you need to build again. Even if your changes were not in the codebehind you must build in order to run the post build event that copies the updated version of your .ascx file.

Hope that helps,

Joe

6/15/2012 7:15:45 AM
Gravatar
Total Posts 3

Re: First Custom Module - Cached Behaviour

Hi Joe,

many thanks for the immediate answer. I have not created a custom project. (Or at least I believe so!)

After downloading the source code, and loaded with VS the mojoportal.sln, I succesfully build it and configured in IIS a new website with root directory the Web folder. My first move was to create a new module. So, I've copied the Modules\EmptyModule.ascx as new one, setup the reference within advanced features, and placed it in a new page. 
I agree, if this was a dll, yes I would expect a new build to be needed. But since its a SiteModuleControl, shouldn't it run from the scratch each time the page loads?

Regards,

PB

6/15/2012 7:34:57 AM
Gravatar
Total Posts 18439

Re: First Custom Module - Cached Behaviour

I don't recommend adding files into the mojoPortal.Web project because then your code is compiled into mojoPortal.Web.dll. If you later upgrade to a new release the dlls will be replaced and your code will be lost.

Even if a control inherits from SiteModuleControl it still has a code behind that is compiled into a dll. It is possible to make a control using inline code instead of codebehind and that will not have a dll and code changes will take place immediately without needing to build, but anytime there is a codebehind .cs files they must be compiled. mojoPortal uses Web Application Project type where all C# code is compiled into dlls in the /bin folder, we don't deploy source code to the production server. There exists also a Web Site Project type in VS that is not used by mojoPortal, in a web site project the source code is deployed and is compiled on demand by the asp.net runtime.

If you want to use inline code you should not copy any module form mojoPortal because mojoPortal is not using inline code. Our hello world examples use inline code, you should use that instead. However for more advanced features I recommend use custom web application projects for your features with codebehind and post build events. You can learn how to do that from our series of videos that walks through building a simple guest book feature.

See also Avoid Forking the Code.

Hope that helps,

Joe

6/15/2012 8:04:36 AM
Gravatar
Total Posts 3

Re: First Custom Module - Cached Behaviour

Thanks again,

I am not a big fan for inline code. I will have a good look in the mentioned videos this weekend and come back!

PB

You must sign in to post in the forums. This thread is closed to new posts.