Saturday, May 30, 2009

Wcf svc mime type on IIS.

I have started exploring WCF. The first issue I have got into was that there is no .svc MIME map on  IIS7 on Vista. When I tried to locate the service I always had the same exception: "HTTP Error 404.3 - Not Found. The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map."



In order to resolve this you need to run "\%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe -i". It will create required .svc mapping.

Regards,
Oleh

Wednesday, May 06, 2009

Variable Scope in JavaScript

Recently I had to add some business logic to the javascript client call back function. I had to iterate through a collection of custom business objects and update state of each of them. I made a mistake in the for loop: declared loop counter not as a local variable!
Instead of
for (var i = 0; i < myCollection.length; i++)
I had
for (i = 0; i < myCollection.length; i++)
The outcome was that I was receiving an error "__pendingCallbacks[...].async is null or not an object" every time my function was executed.


My problem was with the i variable scope. It was declared higher in the stack in the WebForm_CallbackComplete() function
for (var i = 0; i < __pendingCallbacks.length; i++)
so really I was using and updating that variable.



Weird behavior after C# where callee is not able to access its caller's local variables.

But I found my mistake pretty fast.



Hope it helps someone.
Regards,
Oleh

Monday, May 04, 2009

VS2010 .Net Framework 4.0 Developer Certification track updates

Just read about new updates regarding upcoming VS2010 and .NET Framework 4.0 certifications. So far looks like the basic exam (70-536) with no longer be a prerequisite for MCTS developer ones and the MCPD track will be updated but no specific updates were mentioned.

There should be some major changes in new exams topics coverage involved I guess...


Stay tuned!
Regards,
Oleh

Sunday, May 03, 2009

Handle OnLoad event in master page' content page

I wondered how can I add some logic when my master page's content page has been loaded. My javascript code was page specific so I was not able to place it in master page body's onload event handler.
It appeared that there is no built in support for my problem.
But somebody must have experienced this kind of problem before, so I googled and found solution:

MasterPage.master
...
<head>
  <asp:ContentPlaceHolder runat="server" id="Headers">
  </asp:ContentPlaceHolder>
  <script language=javascript>
    function mp_onload()
    {
      if(window.body_onload != null)
      window.body_onload();
    }
  </script>
</head>
<body onload="mp_onload();">
...
This way, if i have a content page that may require an onload event then I just create a function called body_onload in Headers content area of each page that requires it.
Default.aspx
<asp:Content ID="Content2" ContentPlaceHolderID="Headers" Runat="Server">
  <script language="javascript">
    function body_onload()
    {
      //do something
    }
  </script>
</asp:Content>

Original post could be found here.


Hope this helps someone.
Regards,
Oleh