in webforms I would always use my masterpage to set page titles and meta description based on the current url. I was thinking of doing the same for my Asp.net Mvc projects but I ain’t sure where to start. It would be nice to be able to set the title/description based on the controller and/or action with some default values incase I don’t specify any info. The reason why I do this is because I like everything to be in one place because that makes it easy to spot mistakes.
Edit:
After reading the answers and googling some I was thinking it might be cool to get the info from an xml file. With Xml looking something like this:
<website title="default title for webpage">
<controller name="HomeController" title="Default title for home controller">
<action name="Index" title="title for index action" />
</controller>
</website>
I am new to Asp.net Mvc so I am not sure where to initialize this.
So after a few days of trying stuff I ended up with making a custom filter that reads from a XML file.
I added the code to copypastecode.com
http://www.copypastecode.com/9797/
http://www.copypastecode.com/9809/
http://www.copypastecode.com/9805/
I am very novice at Asp.net Mvc and “real” C# coding so if you see strange stuff please forgive me. If somebody wants to optimize it or has a better solution feel free to post it as an answer.
Next thing I am gonna try is to make it without a filter so it’s activated on all controllers. Not sure where to hook up the logic though. So if anybody can push me into the right direction let me know.