Umbraco duplicated master directive - master-pages

Each time we modify an umbraco masterpage outside of the umbraco admin editor we get the whole masterpage wrapped with this directive:
<%# Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
Does anyone know if there's a config flag to avoid this?

I've seen svn merges do this (sometimes repeatedly) where one person has the original empty 'wrapper' master directive - someone else changes it in Visual Studio and then SVN merges all the new changes inside the original wrapper. Especially seems to happen when you change the master inheritance.
So I'm not sure its an Umbraco issue that's solvable with a config key.
EDIT
I'm not certain but usually this behaviour stops when the site edits 'settle down' - I think it is connected to the way the csproj files stores the list of files in the project - once everyone 'include in project' all the masterpages, the problem goes away. But I'm not sure, as its difficult to reproduce once it stops.

Related

following iterative and agile in asp.net MVC

ok, i know there are a lot of posts online that specify how to do iterations with MVC.
my question is slightly different. when i used to do iterations using WebForms, i was creating one thing only and finishing that one thing till the end which was including the deployment on production.
for example, i was creating a webpage and deploying it, then i create the second page and deploy it. so .dll files were added to my bin folder while the previous dlls remain untouched. at the other hand, when i was making a change latter on, there was this one file that needed to be replaced on production.
now here is the question, how can i acheive the same thing in mvc? beause it just doesn't deploy each page into an individual dll. each time that i add something i have to redeploy the application dll which is not really wise! i played around with deployment options in visual studio but no luck!
There is nothing preventing you from putting controllers and other code in separate assemblies and dropping them in an existing application. Like any ASP.NET based application an MVC application will automatically restart if you add or modify any file in the bin folder or modify web.config.
If you're using Razor you can use RazorGenerator to generate code for your views and compile them into the same assembly.
You may need to write some additional logic though to get routes, model binders etc. wired up correctly.
For a more structures approach to compose the application of separate modules, you may want to look into portable areas. This is an extension to ASP.NET MVC that allows you to package the entire module (including views, css, js etc.) into a single assembly.
First thing, you have to work on the title of the post, it does not match the content of the post.
In asp.net mvc u can choose to deploy only what changed. I.e. If you only changed the .cshtml file, then you can just replace it with the file in production. However if you change any controller class (C#/Vb code), then you will have to upload the web project dll file too so that this new changes are available in the production env

How to deploy Umbraco 5 website

I hope I'm asking this question in the right place. I also asked on umbraco forum, but did not get any response yet.
I'm having problem with deploying my Umbraco 5 website to external hosting.
On local machine, I used Umbraco 5 template for VS2010, which works fine (although it's quite slow).
When I publish to live server I get 500 error.
So far, i've tried installing fresh copy of umbraco on hosting (works fine).
I copied config files in hive provider folder (in App_Data), to point umbraco to my hosting database. That does not throw any exceptions yet. Problem starts when I copy views and partial views over - umbraco then finds the template defined in database and tries to load that.
It's worth mentioning that I also copied my project.dll file into bin directory on the server - the reason for that is because I have added new controller which inherits from surfacecontroller (in /Controllers folder).
Please let me know if I'm doing something wrong.
Cheers
Sebastian
It is not any different than deploying a MVC3 website.
There are quite a few questions with exactly that signature here on so.
Visual studio even has a few tools to help you in the process.
The publish function is found right clicking the project in the solution explorer.
If you use the template for developing, you have a working umbraco solution locally right?
If that is the case, it is easier to just deploy / publish the entire site intead of copying bits into another umbraco solution.
Publish tool
When using that tool, remember that umbraco has quite a few config files etc. and they all need to be included. So it is probably the easiest to just export all files in the folders, by changing "which files to include" setting in publish tool. That will unfortunately include all your .cs files too, but later they can be filtered out of the publish process.
First make it work, then make it awesome :)
The same goes for compilation mode, i have found that release mode sometimes breaks things, so for now just keep it in debug mode.
Then later when you have it working, you can change to release mode for a small performance gain.
Stuff to remember
include all necessary files
change connectionstrings
copy databases
custom errors, you don't want your visitors to see YSOD's with your internal debugging info.
disable tracing and debugging!
After reading this, you should go on and look for other more elaborative resources too.
"umbraco then finds the template defined in database and tries to load that" is key point to me
whatever the version you follow the templates and doc types are the backbones of umbraco ( from you website I know that you are aware with above more then me.. but repeating.) I mean you have created new website but there are no relative Templates and Doctype yet you try to use them in views and subviews and that caused the problem.
To do that please create tempalte and doctype same as is in you staging site and this problem will be solved.
Even better kick-start you development with new site only and make replica of that after defining doc-type and templates to your staging.
I hope i can explain my point.
Thanks,
Jigar
I've had problems in the past deploying Umbraco 5 projects. When you deploy an Umbraco 5 website to a new server and before you switch the website on in IIS, navigate to \App_Data\ClientDependency and delete any XML files that are there. Next, navigate to \App_Data\Umbraco\HiveConfig and delete the ConfigurationCache-*.bin files.
Once you've done that, recycle your Application Pool and start your website.

Compile views with enabling MvcBuildViews into MVC 2 Portable Area

I have a big .net mvc 2 project where we are using MvcContrib Portable Area. There is a main web site which load many modules (PA modules).
The main application contains Site.Mater into its ~\Views\Shared folder. each module also has own Site.Master which inherit from that main one.
At the moment we are using something like:
<%# Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" MasterPageFile="~/Views/Shared/Site.Master" %>
After compilation the view handle the main Site.Master right as it is a relative path.
Now I've received a requirement to build views during the compilation. So I've enabled MvcBuildViews = true in each web PA module project.
Of course, I'm getting errors saying "/temp/Views/Shared/Site.Master is not found".
How to keep Portable Area with content embedded and ensure that views do not contain errors?
Any idea?
You can't.
I'm dealing with this same issue and you can't fake the physical location of a file easily.
The only solution is to make a placeholder and removing the non-embedded placeholder file as part of the build process. The benefit of this technique is the non-embedded resource will load a bit faster in development.
Another thing to consider is that loading your views as embedded resources is pretty slow. Having your build process move the centralized "common" views up to the local project will result in better performance for your users.
in case you just want to make sure that everything works fine you could use Watin and write some unit tests that are going to check this

ASP.NET MVC ContentPlaceHolders out of order?

I added a new ContentPlaceHolder (HeadContent) right below the Title so that I can add page-specific css and js files. But when I create a new View using the master page, it puts the default text of the page layout to have the HeadContent open/close tags at the end of the page. Unfortunately, I visually just see it as the first, second and third tags and start typing in my page's html into the last tag. But this isn't the BodyContent place holder because it is the second one. I have to go back and copy/paste them into the correct place. Ugh. Just for kicks, I scrambled all the tags around in the master page just to see what would happen in the view. Sure enough, VS.NET ignores their order in the master page and reorders them the same way everytime.
Why isn't VS just ordering the place holder tags in the same order as in my master page? Actually, how do I make it stop and just do it in the order I have in my master page?
What visual studio is doing (I assume) is loading the MVC View Content Template. I assume the reason all the contents are out of order from your master page is that Visual Studio Extensiblity loads the template then adds any ContentPlaceHolders that are not in the template after the template data.
You can see what the templates look like by going to your Visual Studio file in your Program files then goto Common7\IDE\ItemTemplates\CSharp\Web\MVC2.
There is also a folder for VB. In any case you can open the zip files located in that directory and drill down till you get to the .aspx page and you'll see what VS is inserting into your project when you do a Add New/View.

ASP.Net Share Master Pages, Js, Css across multiple applications

Okay, so I have a couple of ASP.Net Mvc web applications that I would like to share a common master page, some css and js files across...
I tried creating a common repository for the files and then in my studio projects using the Add Existing... As Link... feature but, this doesn't appear to work...
When I try and debug the project I get an error stating the master page cannot be found. Which is because it doesn't physically exist in the location where I created the link...
Has anyone gotten this to work or perhaps have another suggestion on how to share these types of common files...
Thanks..!
If you're using a source control system like SVN, you could keep your master page in one repository and reference that repository with a svn:externals property in your project repositories.
You could then branch the master page if each project required a modification that the other did not, while still maintaining the ability to merge changes made in the original.
You won't be able to share master pages, but it's possible to share static resources like CSS files and Javascripts, but you wouldn't add them to your web application. You'd just reference them in your aspx files and provide their URL.
Where do these files reside? anywhere on the disc or in a folder of some other application?
i don't think it is a good idea because if you have a source control you might need to check in the application source code (including css and js files and masterpages) so someone else on an other machine can run (modify or update) it without problems

Resources