Wednesday, November 26, 2008

ERROR: Components required to enumerate web reference are not installed in V2008

Attending a WCF .Net Framework 3.5 training and came across this error when trying to add Service Web Reference.

"The components required to enumerate web references are not installed on this computer. Please re-install Visual studio"

It is kinda weird as I have a full installation of VS2008 on my computer but somehow it says it is not installed. How come?

What I did:

  1. I actually try to reinstall VS 2008. Then open up the project again and try to add Service Reference. --> RESULTS: Still FAIL.

  2. Google up. Found this magic word "devenv /resetskippkgs". Pump this word into the command prompt. Voila. ---> RESULTS: It SOLVES my problem. (Note that run this magic word on the folder where you installed the VS. In my case, it's "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE").

Solution: Follow step #2 and skip #1.

Monday, October 13, 2008

AJAX - Using UpdateProgress Control and Status Animation

The UpdateProgress control allows you to display progress/status information on a page while an AJAX callback is in progress. It helps you design a more intuitive UI when a Web page contains one or more UpdatePanel controls for partial-page rendering. If a partial-page update is slow, you can use the UpdateProgress control to provide visual feedback about the status of the update.

You can put multiple UpdateProgress controls on a page, each associated with a different UpdatePanel control. Alternatively, you can use one UpdateProgress control and associate it with all UpdatePanel controls on the page.

At the same time, it also allows you to provide the UI to allow user to cancel the AJAX callback if it is taking too long.

Refer to http://www.asp.net/AJAX/Documentation/Live/overview/UpdateProgressOverview.aspx for more information.

In the simple example below, I will associate one UpdateProgress control to one UpdatePanel controls.
<div>















<asp:ScriptManager ID="ScriptManager1" runat="server" />















<asp:UpdatePanel ID="UpdatePanel1" runat="server">















<ContentTemplate>















<asp:TextBox ID="TextBox1" runat="server" />















<asp:Button ID="Button1" runat="server" Text="Update" onclick="Button1_Click" />















</ContentTemplate>















</asp:UpdatePanel>















<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">















<ProgressTemplate>















<img src="images/3MA_processingbar.gif" />















</ProgressTemplate>















</asp:UpdateProgress>















</div>

On the code behind,

Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnUpdate.Click 















System.Threading.Thread.Sleep(4000)















TextBox1.Text = System.DateTime.Now















End Sub

As for the loading indicator icon, you can get it from (thanks to Alan Le):

  1. http://www.ajaxload.info/
  2. http://mentalized.net/activity-indicators/

Sample of indicator gif downloaded from the websites:

Sunday, October 5, 2008

AJAX: Opening a new web page/document using UpdatePanel

Recently, I'm experimenting with AJAX technology to be used in my web application project.
To get more details on AJAX, you can refer to AJAX main website http://www.asp.net/ajax/.

I'm trying to open up a new window when I click on a Button, not the Hyperlink.
Previously, in ASP.Net, I can just use a Response.Write with a javascript window.open function to do that.

Response.Write("<script>window.open('NewPage.aspx');</script>");

However, with AJAX and it's UpdatePanel, I'm getting an error when I pump in this statement in the code behind.

So, with the help of Google and some useful website link, I found this page, http://delroger.wordpress.com/2008/03/26/ajax-an-update-panel-and-opening-a-new-window/ which solves my problem.

To open up a new page/document, you can use RegisterClientScriptBlock function passing the UpdatePanel as the first parameter, the UpdatePanel's type as the second parameter, and so on.

In the example below, str is a variable that contains the javascript statement to open up the Default.aspx page. Then followed by ScriptManager.RegisterClientScriptBlock function. The NewClientScript name is just a name and you can name it anything you like.

string str;
str = "window.open('Default.aspx');";
ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), "NewClientScript", str, true);


... continue exploring AJAX ...

Thursday, September 11, 2008

ERROR: Disallowed Parent Path in ASP page

What happen?
When you open up an ASP page and you get an error:

Active Server Pages error 'ASP 0131'
Disallowed Parent Path
The Include file '../<filename.ext>' cannot contain '..' to indicate the parent directory./<path>/<filename.ext>, line <number>

What's the problem?
If you use relative paths in include statements or when inserting images with Microsoft Active Server Pages (ASP), you will get an error when you browse that page.

This is because by default ASP's "parents paths" for a Web site or application are disabled.

The Solution:
The best solution found from http://support.microsoft.com/kb/226474 is to use the absolute virtual paths from the root of the website instead of the relative paths (...).

Example:
<!--#include virtual="/<virtual path>/<filename.ext>"--> instead of
&lt;!--#include virtual="/<virtual path>/<filename.ext>"-->

Alternative method will be to enable the parent paths, but this is not the preffered method as stated in Microsoft's website. (Refer to their More Information section for details)

As there's too many relative paths used in my apps, I'll just use the second solution.
Steps below are used (for Internet Information Services 7.0):

  1. Start Internet Services Manager.
  2. Click Default Web Site, and then click Properties.
  3. Double-click ASP in the Features pane.
  4. Expand Behavior.
  5. Click Enable Parent Paths.
  6. Click True for Enable Parent Paths.
  7. Click Apply.
Done!

Wednesday, July 30, 2008

Error: Lost ASP Session State on IIS 6.0

What happen?

Recently, I migrated my project's web tools from Windows 2000 to Windows 2003.All is working fine until received an issue from customer saying that they are not able to submit requests through the web tool. They keep redirected back to the main page for no reason.
After doing troubleshooting with customer, I suspected that it has to do with Session as in the web tool, it's using Session to keep track of user's access information. This will only happen if the session has ended/timeout and causing the logic to redirect to main page for re-login.

What's the problem?

Why is the Session keep timeout so fast? Why do we lost the Session so fast even though by default it was suppose to time out in 20 minutes.

The solution?

I googled my problem and found the solution in this blog. http://blogs.msdn.com/david.wang/archive/2005/09/19/Why_do_I_lose_ASP_Session_State_on_IIS6.aspx
Thanks to this blog that it helps to solve my problem.

Basically, the possible causes:

  1. This situation happens if w3wp.exe are recycled. The in-process session state will be lost. As Windows 2003 is using IIS6.0, the ASP session state is stored in-process with whatever w3wp.exe that is executing ASP.DLL to process your ASP application. This state is valid for as long as the w3wp.exe is running.
  2. Enabling Web Gardens, where maximum number of worker process > 1. Web Garden introduces multiple processes to service requests while in-process state is not automatically copied across processes. If you have code that relies on sessions, and you enable the web garden feature (set max processes to > 1 for an app pool), you will experience this "curious" "intermittent" loss of sessions (or "unexplainable logouts"). The problem isn't work process recycling, nor even application domain restarts (other problems that can kill sessions or force logouts). Instead, it's just that the web garden feature can cause your requests to eventually be directed to a new worker process where the session you had is not existing.

Try:

  1. Disable periodic recycling.
  2. Try not enable web gardens (if not needed)

Wednesday, June 18, 2008

ERROR: Validation of viewstate MAC failed

Encounter this problem when using AutoPostBack in my web application which uses ViewState.

Error: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

Specs:
Microsoft Visual Studio 2005 .Net Framework 2.0
Windows Server 2003

Tried to google for solution and found this workaround which helps to solve my problem.
Link: http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic49235.aspx

Solution:
Add the code below into the web.config file.
<system.web>
<pages enableViewStateMac="false" />
<system.web>