Ideas and thoughts about Microsoft Identity, C# development, cabbages and kings and random flotsam on the incoming tide
Wednesday, February 29, 2012
Visual Studio : "Set As Start Page" doesn't work in the real world
So in Visual Studio 2010, I right click the "abc.aspx" page and select "Set As Start Page".
Hit F5 - works perfectly.
Deploy it to a real IIS 7 server and WTF - Default.aspx is displayed in all its delights?
Turns out the "Set As Start Page" option only applies to Cassini - the VS internal web server (which is why it works when you hit Run ( = F5)).
In the real world, you have to go to the web site inside the IIS Manager, select "Default Document" and then type abc.aspx and move it up to the top.
There you go!
Enjoy!
msdeploy : Package installation failed - 'managedRuntimeVersion' differs
I got the error:
The package installation failed.
Details:
The application pool that you are trying to use has the 'managedRuntimeVersion' property set to 'v4.0'. This application requires 'v2.0'.
My web application used the "Default Web Site" and the application pool that it was connected to (DefaultAppPool) was .NET Framework 2.0. Yeah - I screw around with IIS a lot!
Of course, where I was deploying it to was the more usual .NET Framework 4.0.
Mr. Google to the rescue and the answer is to set the following options under the project / Properties / Package/Publish Web:
You need to tick the two text boxes "Include IIS Settings" and "Include application pool settings".
And away you go with msdeploy.
Enjoy!
Wednesday, February 22, 2012
WIF : Web Platform Installer
Just search on the keyword "identity".
Hey - hey - it's becoming mainstream.
Makes it just that bit easier to download.
The WPI is a really useful tool that collects a pile of Microsoft (and other) downloads in one place. Well worth 5 minutes of your time to go and have a look!
Enjopy!
Monday, February 13, 2012
C# : Some basic validation
Doing some basic validation and I found these to be useful:
Check for mandatory fields:
if (String.IsNullOrEmpty (xxx)) … error
Field must be numeric only:
int number;
bool result = Int32.TryParse (xxx, out number);
if (!result) … error
Valid date format:
DateTime date;
bool result = DateTime.TryParse (xxx, out date);
if (!result) … error
Valid email format:
bool result = Regex.IsMatch(xxx, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)
(([\w-]+\.)+))([a-zA-Z]{2,4}[0-9]{1,3})(\]?)$");
if (!result) … error
Enjoy!
WCF : soapUI error "BadContextToken"
While soapUI is a really useful tool for web service unit testing, it doesn’t work with WCF.
In particular, with the default "wsHttpBinding", you get the message "BadContextToken".
Mr. Google comes back with tons of results about why soapUI doesn’t play nicely with WCF and recommends WCF Storm which looks good but it’s not free.
So a whack of investigation later:
Add the following binding into the <bindings> section of your web.config:
<!-- soapUI -->
<wsHttpBinding>
<binding name="wsHttpBindingNoSecurity">
<security mode="None">
<transport clientCredentialType="None" />
<message establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
Add the following "bindingConfiguration” parameter to your <endpoint> section:
binding="wsHttpBinding" bindingConfiguration="wsHttpBindingNoSecurity"
The WCF service has an endpoint like:
blahblah.svc
For soapUI you need to change this to blahblah.svc?wsdl when you “Add WSDL”.
Once you’ve added the service to soapUI, click the default operation and then click the “WS-A” tab at the bottom.
Click “Enable/disable WS-A addressing”.
Click “Add default wsa:Action”.
Click “Add default wsa:To”.
And (finally) success!
REMEMBER: Every time you change the web.config, you need to right-click the soapUI service and “Update Definition” or F5!
Enjoy!
Wednesday, February 08, 2012
Visual Studio : Showing the active file in the Solution Explorer tree
Something I've always thought would be really useful.
Turns out the way to do this is via:
Tools / Options / Projects and Solutions / General / Click "Track Active Item in Solution Explorer".
WTF isn't this the default?
Enjoy!