Monday, June 9th, 2008
Sometimes .NET really winds me up. Why do they by default put things that could potentially give a hacker some information. I know security by obscurity is not the best way forward but why leave your front door open!
Anywho - it is really easy to get rid of:
Find or add the element <httpRuntime> in your web.config and add the attribute enableVersionHeader=”false”.
The msd documentation can be found here: http://msdn.microsoft.com/en-us/library/e1f13641.aspx
Posted in .NET | No Comments »
Sunday, May 25th, 2008
Posted in .NET | No Comments »
Wednesday, May 21st, 2008
You don’t always have to use the old:
ConfigurationManager.AppSettings["whatever"]
In a master page you can also use a bit of short hand:
<%$ AppSettings:whatever%>
Saves some typing a suppose…
Posted in .NET | No Comments »
Tuesday, May 20th, 2008
The standard white background is a little boring and if you are looking at it all day it gets a bit bright so I thought I would have a change.
I found a few that I liked from here and here
I took one and altered it to my liking.
Posted in .NET | No Comments »
Monday, May 19th, 2008
This is fine if you just let .NET generate your client side script - but what if I want to write my own? What options do I have?
- Alter all your ID’s in your script as they will always be mangled the same! - I would rather not thanks..
- Change the ID’s in your script at runtime - not great but better
- Got any better ideas?
VB I know but you still get the idea:
Dim script As String = “[Label1ID].innerHTML = ‘boo!’;”
Dim scriptKey As String = “SayBoo”
Dim addScriptTags As Boolean = True
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As EventArgs)
script = script.Replace(“[Label1ID]“, Label1.ClientID)
ClientScript.RegisterStartupScript( _
Me.GetType(), scriptKey, script, addScriptTags _
)
End Sub
Thanks to: http://www.odetocode.com/articles/450.aspx
Posted in .NET | No Comments »
Monday, May 19th, 2008
At first I thought the best approach would be to use a content place holder but then I thought no this is .NET and the framework should have a way to let me do this a little more elegantly (I do like my code to be elegant)
So the way I plumped to do this was to use the HtlmHead object. The MasterPage exposes the Head element and you can add attributes like so:
HtmlHead head = (System.Web.UI.HtmlControls.HtmlHead)Header;
HtmlMeta keywords = new HtmlMeta();
keywords.Attributes.Add(”name”, “keywords”);
keywords.Attributes.Add(”content”, Product.Keywords);
head.Controls.Add(keywords);
Dead easy really. Whilst Googling I did find some other useful info on MasterPages - fixing those mangled ID’s in master pages etc!
Simpler:
HtmlMeta tag = new HtmlMeta();
tag.Name = "description";
tag.Content = "My description for this page";
Header.Controls.Add(tag);
Posted in .NET | No Comments »
Wednesday, May 14th, 2008
Posted in .NET | No Comments »
Saturday, May 10th, 2008
Dead easy to do:
Add the profiles to the web.config
<?xml
version=”1.0″?>
<configuration>
<system.web>
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name=”StaticPageCacheProfile” duration=”14400″ />
<add name=”UserControlCacheProfile” duration=”60″ />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
</configuration>
Then just add that to the page declaration:
<%@ OutputCache CacheProfile=”StaticPageCacheProfile” VaryByParam=”none” %>
It would also be a good idea to separate out the cache profiles to a separate config file and then use MSBuild to pull the correct ones in at deploy time. I hate forgetting to change the profile when you are working on the site on DEV and it doesn’t change or a designer comes over telling you nothing has changed!
Posted in .NET | No Comments »
Friday, March 21st, 2008
Posted in .NET | No Comments »
Sunday, March 16th, 2008
Posted in .NET | No Comments »