Thursday, February 2, 2012

401 Error when doing postbacks while on Juniper VPN

I recently at a customer was faced with a problem where a web application developed on .Net 4.0 using forms authentication, was working fine on the local network, however when accessed by our offshore development team via the Juniper VPN infrastructure returned the following error message:

HTTP Error 401.1 - Unauthorized: Access is denied due to invalid credentials.
Internet Information Services (IIS)

We initially found the error on pages that contained the SQL Server Repoting Services report viewer control.

The error seemed to be Ajax related and occurred on partial page post backs. We quickly realised that Juniper has a built in URL re-writer engine. Juniper converted the URLS into a format that it would use to proxy web requests to the web application running onsite at the customer.

The sample URL created by Juniper:

https://portal.customer.co.za/Content/Home/,DanaInfo=secure.customer.intranet.dev+Portfolio.aspx

We used fiddler to check what the browser was requesting from the Juniper server and realized that the URL was being changed using the URL re-writer feature.

Juniper is a browser based VPN solution, that abstracts the network access provided on other VPN solutions and allows remote users to access web applications through a secure proxy server, without giving them access to your full network.

The web application would render correctly, however when the user did a partial post back, Juniper does not always provide the post back URL in the correct format, resulting the error above.

We requested that the Juniper configuration team switch off the URL re-writer functionality. This resolved the issue. Juniper’s online documentation for version 7.0 says that it does support Microsoft Ajax functionality, we did not have enough time to verify if this was available in the supported configuration.

Friday, July 30, 2010

Problem creating a proxy class for a java web service using WseWsdl3.exe

I recently ran into a problem creating a proxy class for a Java web service using WseWsdl3.exe. The project would build just fine, however when an instance of the service class was created the following error was raised:

"Unable to generate temporary class (result=1) error CS0266: Cannot implicitly convert type object to Object[]"

The following article helped me realise that the WSDL generation tools will only be able to provide a best guess class definition and that you may in some cases need to tweak the generated code.

HOW TO: Change Types Used in Proxy Classes That Are Generated with Wsdl.exe

The following section shows the object definition from the wsdl:

<xs:complexType name="searchResult">
<xs:sequence>
<xs:element name="iteratorID" type="xs:decimal" minOccurs="0" />
<xs:element name="obj" type="ns1:anyTypeArray" nillable="true" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>

When a wsdl schema is published that contains nested nodes that have the maxOccurs attribute set to the "unbounded" value, the Wsdl.exe and WSEWsdl3.exe tools create multidimensional arrays in the generated code file. Therefore, the generated code contains incorrect types for the nested nodes. To solve the problem modify the generated code by removing the bracket ([]) array characters from the data type.

Only do this if you know that the service is going to return a single instance of an object.

In my case, I needed to change the following

private object[][] objField;

to

private object[] objField;

Monday, July 19, 2010

SharePoint site page title dissapears on page load

The page title on our SharePoint site disappeared after some code changes on the master page. Initially we thought SharePoint was doing something strange and found a work around that tried to resolve the problem by storing the site title in a global variable on page init and setting the document title once the page had fully loaded.
The title section in the header looked as follows:




Changing the title to the following format resolved the problem:



Strange but true.












Thursday, April 15, 2010

Ajax and SharePoint web part loading

One of the marvels of modern web technology is the ability to communicate with the web server asynchronously using partial postbacks. This ensures that the web application behaves more like a desktop application and there are no full page refreshes required to reload the information that is hosted on a web page. Since 2005 Ajax has been used as a mainstream web development technique and has support from most software vendors including Microsoft.

Having the ability to reload only the areas of a web page that are required, improves the user experience and eliminates the page flickers that plagued early web applications. The benefits of using Ajax are really only seen on the client side, with very little to no changes in the web server infrastructure. The web request method still relies on a single call to request the web page content and does not support simultaneous requests.

If your web part relies on server requests to provide data to the UI, you may consider queueing the requests to ensure that the web parts each get a turn to request their information. The benefit of this approach is that the web parts will render their content and issue a postback once the entire page has been rendered.

The following script will enqueue post back requests and issue them in sequence for each web part.

Tuesday, April 13, 2010

SharePoint and Ajax Postback issue

SharePoint Server is a great application platform that has rich out of the box functionality. Building custom solutions on SharePoint may require a little more research to ensure that you are able to implement modern UI capabilities. One of the issues we found recently is that SharePoint in its native configuration does not support simultaneous postbacks.

Our design goal was to build web parts that behaved independently and that would issue postbacks as each part was loaded. This would allow the web page UI to load while the data was being fetched in the background.

Once we had built our Asp.Net user controls we found that they did not work as expected in a SharePoint enviornment. This relates to the way that Sharepoint handles post backs and a fix that Microsoft implemented to cater for double byte url's. Luckily the fix is quite easy to implement, that is once you have identifed the reason why subsequent post backs were failing.

Adding the following two lines of javascript code at the top of the web page solved the problem.

_spOriginalFormAction = document.forms[0].action;
_spSuppressFormOnSubmitWrapper=true;

Sunday, March 21, 2010

Slow Virtual PC on Windows 7 x64

The Windows 7 platform has changed the way we work and has introduced new levels of hardware abstraction that has never been seen before in the desktop and mobility markets. We are now able to boot directly into a virtual machine. This allows us to run multiple virtual desktop systems, based on our context and working role. As a software developer I find this useful to switch between my desktop developer environment and my consulting environment where i run product demos and power point presentations.

I recently discovered that while the technology was available the end user experience was not as smooth as I would have imagined it should be. I have seen many posts online with simillar symptoms. After I installed my new laptop with Windows 7 Ultimate x64 and installed the new Windows 7 virtual pc and XP mode, the virtual machine running Windows Server 2008 R2 was extremely slow and I was unable to work.

After some research the following items resolved my VM performance issue.

1. Install the following in sequence:
- WindowsXPMode_en-us.exe
- Windows6.1-KB958559-x64.msu
- Windows6.1-KB977206-x64.msu

2. Next install the Integration Features, very important.

3. Add your VHD folder to the exclude files and location on Microsoft Security Essentials. (Probably the main culprit)

4. Add the VMWindow.exe and vpc.exe processes to the Exclude Processes section in Microsoft Security Essentials.

5. Adjust the display for performance in the VM:




6. Adjust performance for programs in the VM:




7. Run windows update on the virtual machine. This ensures that you get the latest bits to support the hardware virtualisation.

Hope this helps anyone with performance issues in Windows 7 x64 virtual machines.

Monday, March 8, 2010

OSI SOFT RtWebParts on Windows Server 2008 R2

The OSI Soft RtWebparts add rich data visualisation capabilities to plant monitoring and Manufacturing Execution Systems. SharePoint Server provides the ideal application framework to host these parts and integrate LOB applciations with real-time plant information.

These parts Initially when we started testing with Windows Server 2008, we ran into the following issue which was reported in the application event log.

"Unable to access SCM Manager. 5 in AFManager::OnThreadStart”

The Pi services are not configured with sufficient rights to execute on a Server 2008 environment. Run the following commands at the command prompt with Administrator privileges to resolve the issue:

To query the current service permissions use the following command line option:
sc sdshow SCMANAGER
sc sdshow PINETMGR

Replace with the following settings:

NOTE: The entry for sdset must be on a single line in order for the changes to be made. Applying the security acl in the incorrect format can render the service unusable.

sc sdset PINETMGR D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA) (A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)S:AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)


sc sdset SCMANAGER D:(A;;CCLCRPRC;;;AU)(A;;CCLCRPRC;;;IU)(A;;CCLCRPRC;;;SU)(A;;CCLCRPWPRC;;;SY)(A;;KA;;;BA)S:(AU;FA;KA;;;WD)(AU;OIIOFA;GA;;;WD)