Blog Stats
  • Posts - 5
  • Articles - 0
  • Comments - 8
  • Trackbacks - 3

 

Tuesday, March 13, 2007

MOSS 2007

It has been a while but nothing excited has really happened to write about until a few weeks ago.  I started playing around with MOSS 2007 (Microsoft Office Sharepoint Server 2007).  To read more about it:  http://office.microsoft.com/en-us/sharepointserver/default.aspx

I am currenlty looking at the Business Data Catalog (BDC) in MOSS.  Martin Kearn give an excellent overview here:  http://blogs.msdn.com/martinkearn/archive/2006/10/05/What-is-the-Business-Data-Catalouge_3F00_.aspx

There is also a pretty good information on MSDN: http://msdn2.microsoft.com/en-us/library/ms563661.aspx

Other parts of MOSS that has peaked my interest is InfoPath and Excel Services.  Both technologies that will make life a lot simpler for all of us in the future.

Wednesday, August 09, 2006

Web Service Call Error: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server

We call our web services through TAM.  Of course this is never done in development so when we started testing one of our applications the other day we got the following error: “The underlying connection was closed: A connection that was expected to be kept alive was closed by the server”.  This happened on subsequent calls to services through the TAM from our .Net application and did not seem to happen from the Java side.  The first call will work fine but the second or third call will fail with the above mentioned error message.

 

We at first used the approach as described by Microsoft (http://support.microsoft.com/default.aspx?scid=kb;EN-US;915599) and did a proxy class for every one of our service calls in which we then set the Keepalive property to False.  Here is the code:

public class MyServiceProxy : MyService

{

protected override System.Net.WebRequest GetWebRequest(Uri uri)

{

System.Net.HttpWebRequest webRequest =

(System.Net.HttpWebRequest)base.GetWebRequest(uri);

webRequest.KeepAlive = false;

return webRequest;

}

}

 

This solved the issue but we got a little concerned about performance since we will force the connection close after every call.  We also are very close to UAT on our application and did not want to make significant code changes to all our service calls.

 

After some digging around we found a timeout setting for keeping connections alive on the TAM server.  This setting was set to 5 seconds on the server.  The corresponding setting inside the .Net framework (MaxServicePointIdleTime setting in ServicePointManager static class) was set to 100 seconds.

 

This change is done on a global level and we have decided to do that at session start in our web application.  This setting is in milliseconds so we now have that set to 30000.

 

We have not seen the error again and we need to do load testing now but all indications are that this will be a good solution.

 

Thursday, July 20, 2006

Visual Studio web Form Designer message "If you have references in markup, they will not be renamed"

A day or so ago I started getting the message “If you have references in markup, they will not be renamed” in my ASP 2.0 project whenever I change a control name on my page. 

At first I thought it was because I just added a master page to all my pages and that is causing some issues.  I decided to live with it for now since most of my development is done and I am just cleaning up stuff.  But as expected the users now want a few more “fields“ on the page.  Then it really got on my nerves. 

I started looking around and found a entry by Rick Strahl (http://west-wind.com/weblog/posts/3192.aspx) that pointed me to the Visual Studio bug list where this has been reported and two workarounds are posted there: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101992

A quick summary of the workarounds (both worked for me):

The quick fix is to make VS re-build the web site cache:
a) shut down all instances of VS
b) remove cache from command prompt> rd /s /q "%userprofile%\Local Settings\Application Data\Microsoft\WebsiteCache"
c) re-open your web site and the cache will be re-created

An alternative method to fix the one web site without deleteing the entire cache is the following:
a) shut down all instances of VS
b) open "%userprofile%\Local Settings\Application Data\Microsoft\WebsiteCache\websites.xml"
c) locate the entry for your web site and get its CacheFolder name. Usually the name of the web.
d) Ensure a sub-directory of that name exists under "%userprofile%\Local Settings\Application Data\Microsoft\WebsiteCache\"

Enjoy.

PS:   I also found the shortcut key for switching between markup and design view.  It is CTRL-Page Up or CTRL-Page Down.

Wednesday, July 12, 2006

Using a password protected certificate with HTTPWebRequest

Yesterday I got the task to do a “quick” POC to test a call to a service (without SOAP) using a client certificate.  First of all please do not ask why we want to do it without SOAP.  That is a very loooong story.

After some initial poking around I found a few good links:

·        http://blogs.msdn.com/adarshk/archive/2004/09/01/224214.aspx

o       This is adarsh blog and I liked it because it is short and sweet and it put me on the right track.  Only ugly part is that this example was for .Net 2.0 beta so the X509CertificateEx class has been renamed to X509Certificate2.  It is still in the System.Security.Cryptography.X509Certificates namespace.

·        http://support.microsoft.com/kb/895971/en-us

o       This article is for .Net 1.0 and 1.1 but have some good tips if you want to see the installed certificates on your machine.

I ended up with a pretty clean solution but are having a weird problem when I run it on the server.  I get the following error sometimes and am trying to find a solution for this now (will keep you posted):

The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.

I found some good info here:  http://weblogs.asp.net/jan/archive/2004/05/08/128394.aspx.  This is for WSE but it has fixed my problem as well.

Here is the current code I am playing with (and it works):

Some important using statements for this to work:

using System.IO;

using System.Net;

using System.Security.Cryptography.X509Certificates;

using System.Net.Security;

using System.Security.Policy;

private void SecureTest(){

try{

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(“http://myurl/TestService”);

req.Method = "POST";

req.KeepAlive = false;

X509Certificate2 Cert = new X509Certificate2();

string CertPath = “c:\temp\cert.p12”;

string CertPwd = “certpassword”;

Cert.Import(CertPath, CertPwd, X509KeyStorageFlags.PersistKeySet);

req.ClientCertificates.Add(Cert);

Stream s = req.GetRequestStream();

StreamWriter sw = new StreamWriter(s);

sw.Write(txtInput.Text);

sw.Close();

s.Close();

// submit synchronous HTTP request to Web server

WebResponse rsp = req.GetResponse();

// WebResponse provides stream-based access so let's go get it baby

StreamReader sr = new StreamReader(rsp.GetResponseStream());

txtSecureOutput.Text = sr.ReadToEnd();

}

catch (Exception ex) { throw ex; }

}

VB, C# and MTBC (my three brian cells)

I have been a VB guy since VB3.0.  IMHO it is the most productive language available.  I flunk out of typing school so typing is not for me.  VB has over the years made coding so easy without scarifying performance.  When .Net was released it was tough to not have some of the productivity features we were used to for years like “Edit and Continue” etc.  Most of that is now back again in VS 2005 and I am very happy.  If you are still using VB6 now is the time to switch to .Net.

 

I was also never big on the web applications.  It sure has a rightful place in our world.   I have done some web stuff and really like what is available in VS 2005 and ASP.Net 2.0.  I am also very excited about ATLAS.  It gives us a lot of features (based on the AJAX platform) that we used to either live without or had to code lines and lines of JavaScript to accomplish.  It is still in Beta but it is slick.

 

Recently I took a new job and my first few projects are C# and all are on ASP 2.0.  So as you can imagine I now have to do the wild thing and read documentation again.  My head hurts.  I only have three brain cells left and they are all preserve in some malted beverage for use (or abuse) by the next generation.  I have a hard time every morning to get the three of them going.

 

I am getting awfully familiar with C# now and although I do not mind using it I must say that I still prefer VB over C#.  It is just way more productive of a language and once it becomes IL it is all the same in any case.

 

 

Copyright © Ignus Bezuidenhout